분명 위에있는 소스코드 앞전에 했을때 안되었는데 다시하니 잘됩니다. 감사합니다.
import부분은 다 잘되었는데 실행해보니
Traceback (most recent call last):
File “c:\Users\ILNARA\OneDrive\바탕 화면\chatgpt\chatgpt blog\app.py”, line 12, in
model=”text-davinci-003″,
^^^^^^^^^^^^^^^^
File “C:\Users\ILNARA\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\openai\api_resources\completion.py”, line 25, in create
return super().create(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\ILNARA\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\openai\api_resources\abstract\engine_api_resource.py”, line
149, in create
) = cls.__prepare_create_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\ILNARA\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\openai\api_resources\abstract\engine_api_resource.py”, line
requestor = api_requestor.APIRequestor(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\ILNARA\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\openai\api_requestor.py”, line 130, in __init__
self.api_key = key or util.default_api_key()
^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\ILNARA\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\openai\util.py”, line 186, in default_api_key
raise openai.error.AuthenticationError(
openai.error.AuthenticationError: No API key provided. You can set your API key in code using ‘openai.api_key = ‘, or you can set the environment variable OPENAI_API_KEY=). If your API key is stored in a file, you can point the openai module at it with ‘openai.api_key_path = ‘. You can generate API keys in the OpenAI web interface. See https://platform.openai.com/account/api-keys for details, or email support@openai.com if you have any questions.
PS C:\Users\ILNARA\OneDrive\바탕 화면\chatgpt> & C:/Users/ILNARA/AppData/Local/Microsoft/WindowsApps/python3.11.exe “c:/Users/ILNARA/OneDrive/바탕 화면/chatgpt/chatgpt blog/app.py”
None
Traceback (most recent call last):
File “c:\Users\ILNARA\OneDrive\바탕 화면\chatgpt\chatgpt blog\app.py”, line 11, in
response = openai.Completion.create(
^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\ILNARA\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\openai\api_resources\completion.py”, line 25, in create
return super().create(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\ILNARA\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\openai\api_resources\abstract\engine_api_resource.py”, line
149, in create
) = cls.__prepare_create_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\ILNARA\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\openai\api_resources\abstract\engine_api_resource.py”, line
106, in __prepare_create_request
requestor = api_requestor.APIRequestor(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\ILNARA\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\openai\api_requestor.py”, line 130, in __init__
self.api_key = key or util.default_api_key()
^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\ILNARA\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\openai\util.py”, line 186, in default_api_key
raise openai.error.AuthenticationError(
openai.error.AuthenticationError: No API key provided. You can set your API key in code using ‘openai.api_key = ‘, or you can set the environment variable OPENAI_API_KEY=). If your API key is stored in a file, you can point the openai module at it with ‘openai.api_key_path = ‘. You can generate API keys in the OpenAI web interface. See https://platform.openai.com/account/api-keys for details, or email support@openai.com if you have any questions.
이런식으로 또 뜨네요.
댓글 1개
안녕하세요. 현재 파이썬버젼때문인지 dotenv openai를 설치했는데도 모듈이 없다고 나오고있습니다. 버젼을 바꿔야할까요? 아니면 새로운 버전에서는 다른것도 설치를 해야하나요? 답변부탁드립니다.
pip install python-dotenv
이 코드로 진행하여도 모듈이 없다고 나오는지요?
분명 위에있는 소스코드 앞전에 했을때 안되었는데 다시하니 잘됩니다. 감사합니다.
import부분은 다 잘되었는데 실행해보니
Traceback (most recent call last):
File “c:\Users\ILNARA\OneDrive\바탕 화면\chatgpt\chatgpt blog\app.py”, line 12, in
model=”text-davinci-003″,
^^^^^^^^^^^^^^^^
File “C:\Users\ILNARA\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\openai\api_resources\completion.py”, line 25, in create
return super().create(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\ILNARA\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\openai\api_resources\abstract\engine_api_resource.py”, line
149, in create
) = cls.__prepare_create_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\ILNARA\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\openai\api_resources\abstract\engine_api_resource.py”, line
requestor = api_requestor.APIRequestor(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\ILNARA\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\openai\api_requestor.py”, line 130, in __init__
self.api_key = key or util.default_api_key()
^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\ILNARA\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\openai\util.py”, line 186, in default_api_key
raise openai.error.AuthenticationError(
openai.error.AuthenticationError: No API key provided. You can set your API key in code using ‘openai.api_key = ‘, or you can set the environment variable OPENAI_API_KEY=). If your API key is stored in a file, you can point the openai module at it with ‘openai.api_key_path = ‘. You can generate API keys in the OpenAI web interface. See https://platform.openai.com/account/api-keys for details, or email support@openai.com if you have any questions.
PS C:\Users\ILNARA\OneDrive\바탕 화면\chatgpt> & C:/Users/ILNARA/AppData/Local/Microsoft/WindowsApps/python3.11.exe “c:/Users/ILNARA/OneDrive/바탕 화면/chatgpt/chatgpt blog/app.py”
None
Traceback (most recent call last):
File “c:\Users\ILNARA\OneDrive\바탕 화면\chatgpt\chatgpt blog\app.py”, line 11, in
response = openai.Completion.create(
^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\ILNARA\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\openai\api_resources\completion.py”, line 25, in create
return super().create(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\ILNARA\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\openai\api_resources\abstract\engine_api_resource.py”, line
149, in create
) = cls.__prepare_create_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\ILNARA\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\openai\api_resources\abstract\engine_api_resource.py”, line
106, in __prepare_create_request
requestor = api_requestor.APIRequestor(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\ILNARA\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\openai\api_requestor.py”, line 130, in __init__
self.api_key = key or util.default_api_key()
^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\ILNARA\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\openai\util.py”, line 186, in default_api_key
raise openai.error.AuthenticationError(
openai.error.AuthenticationError: No API key provided. You can set your API key in code using ‘openai.api_key = ‘, or you can set the environment variable OPENAI_API_KEY=). If your API key is stored in a file, you can point the openai module at it with ‘openai.api_key_path = ‘. You can generate API keys in the OpenAI web interface. See https://platform.openai.com/account/api-keys for details, or email support@openai.com if you have any questions.
이런식으로 또 뜨네요.
현재 소스코드는:
from dotenv import load_dotenv
load_dotenv()
import os
import openai
openai.api_key = os.getenv(“OPENAI_API_KEY”)
print(os.getenv(“OPENAI_API_KEY”))
input()
response = openai.Completion.create(
model=”text-davinci-003″,
prompt=”나는?”,
temperature=0.9,
max_tokens=150,
top_p=1,
frequency_penalty=0.0,
presence_penalty=0.6,
stop=[” Human:”, ” AI:”]
) 이거입니다.
?? 선생님께서 전달해주신 코드로 실행시켰을때 정상적으로 작동됩니다 !
참고로 OPENAI_API_KEY = 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입니다. 바쁘실텐데 많은 문의드려죄송합니다.
API Key는 노출되었을때 다른 사람이 사용할 수도 있습니다 선생님 !
발급받으셨던 API Key 삭제후 -> 댓글 삭제 or 수정하시는게 좋으세요
재발급 받아서 다시해보겠는데도 오류가나는데 설정문제 일까요?ㅜㅜ