openai / openai-quickstart-python

Python example app from the OpenAI API quickstart tutorial
https://platform.openai.com/docs/quickstart?context=python
MIT License
1.66k stars 1.31k forks source link

ModuleNotFoundError: No module named 'openai' #40

Closed ihazem closed 4 months ago

ihazem commented 1 year ago

In following the instructions here, I got the below error. It was defaulting to my anaconda flask lib. The instructions should probably point the user to use flask in the venv. Suggestion to change the command in the doc to be ./venv/bin/flask run, as that worked for me.

(venv) /Users/<username>/Documents/Development/openai-quickstart-python % flask run
 * Tip: There are .env or .flaskenv files present. Do "pip install python-dotenv" to use them.
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
Usage: flask run [OPTIONS]
Try 'flask run --help' for help.

Error: While importing "app", an ImportError was raised:

Traceback (most recent call last):
  File "/Users/<username>/opt/anaconda3/lib/python3.8/site-packages/flask/cli.py", line 240, in locate_app
    __import__(module_name)
  File "/Users/<username>/Documents/Development/openai-quickstart-python/app.py", line 3, in <module>
    import openai
ModuleNotFoundError: No module named 'openai'
francomariani94 commented 1 year ago

Try with: python -m flask run

logankilpatrick commented 4 months ago

Hey! Make sure you have the latest SDK version from: https://github.com/openai/openai-python