Closed mithunsridharan closed 1 year ago
Hi @mithunsridharan! I can't create this with the reproduction steps above. I strongly suspect a configuration issue on your side (either a conflicting file name / module with subprocess, or something else in your dev setup). Please let me know if you have other steps that might help me reproduce the error.
Describe the bug
I'm facing issues with openai on Python 3.11.2. When I run the demo code, I'm getting the following issues. I suspect there's an issue due to a space in the Python file path. Please let me know of any workaround or fixes:
Please note that the Python script is in a folder: Z. Temp This folder has a space.
/Users/mithun % /usr/local/bin/python3 "/Users/mithun/Documents/Z. Temp/Python/GPT_Test2.py" Traceback (most recent call last): File "/Users/mithun/Documents/Z. Temp/Python/GPT_Test2.py", line 1, in
import openai
File "/usr/local/lib/python3.11/site-packages/openai/init.py", line 9, in
from openai.api_resources import (
File "/usr/local/lib/python3.11/site-packages/openai/api_resources/init.py", line 1, in
from openai.api_resources.audio import Audio # noqa: F401
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/openai/api_resources/audio.py", line 4, in
from openai import api_requestor, util
File "/usr/local/lib/python3.11/site-packages/openai/api_requestor.py", line 1, in
import asyncio
File "/usr/local/Cellar/python@3.11/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/init.py", line 8, in
from .base_events import *
File "/usr/local/Cellar/python@3.11/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py", line 40, in
from . import events
File "/usr/local/Cellar/python@3.11/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/events.py", line 203, in
class AbstractEventLoop:
File "/usr/local/Cellar/python@3.11/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/events.py", line 511, in AbstractEventLoop
stdin=subprocess.PIPE,
^^^^^^^^^^^^^^^
AttributeError: module 'subprocess' has no attribute 'PIPE'
However, when I run the sample code from MacOS Desktop, I'm no longer getting the subprocess error, but rather the expected API key error. Note that the file path does not have any spaces.
/Users/mithun % /usr/local/bin/python3 /Users/mithun/Desktop/GPT_Test2.py Traceback (most recent call last): File "/Users/mithun/Desktop/GPT_Test2.py", line 5, in
models = openai.Model.list()
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/openai/api_resources/abstract/listable_apiresource.py", line 60, in list
response, , api_key = requestor.request(
^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/openai/api_requestor.py", line 226, in request
resp, got_stream = self._interpret_response(result, stream)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/openai/api_requestor.py", line 619, in _interpret_response
self._interpret_response_line(
File "/usr/local/lib/python3.11/site-packages/openai/api_requestor.py", line 682, in _interpret_response_line
raise self.handle_error_response(
openai.error.AuthenticationError: Incorrect API key provided: sk-dvmDm***po9e. You can find your API key at https://platform.openai.com/account/api-keys.
To Reproduce
Execute the sample code on MacOS Desktop and another folder with a space in the file path
Code snippets
OS
macOS
Python version
Python v3.11.2
Library version
openai-python v0.27.2