Forum in maintenance, we will back soon 🙂
Connecting OpenAI module
I keep getting the same error when trying to import openai: ModuleNotFoundError: No module named 'openai'
You can see on the image that it's giving me the error without even running the script (but I did try to run it several times)
However when I search I can see that it's been installed:
monikamileva@MacBook-Pro ~ % openai --version
openai 1.30.5
Not sure what to do.
Â
Â
@monika-mileva you need to
mkdir MYPROJECT cd MYPROJECT python3 -m venv VENV source VENV/bin/activate pip install openai
You always want to encapsulate your project in its own virtual environment.
You can substitute whatever you want for the objects in my instructions with capital letters like MYPROJECT, VENV, etc.
Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack
@ssadvisor there's nothing like this mentioned in the lesson. I did try what you suggested but I'm still getting exactly the same error. It would be great if we had a proper step-by-step tutorial rather than written instructions.
@monika-mileva which lesson are you trying to do? Give me the link to the lesson. Also, what is the "openai" app that you're using?
Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack
@ssadvisor this is the link for the lesson https://learnwithhasan.com/lessons/connect-python-with-openai-api/
I'm not sure what you mean by "app" There's no app to be used in this lesson. The only thing I need to change for this lesson is use my own API key. But my problem is that when I type import openai the error shows straight away. And even when I followed your advice and created a virtual environment I cannot import. But I can see it in the environment.
I also tried to move my chatgpt.py file in different places around to see if it wil make any difference and it didn't.
@monika-mileva by app I mean when you doÂ
openai --version
you receive a response of
openai 1.30.5
Two things I see in this picture, you have yet to save the file chatgpt.py and you have not installed with pip the openai module.
Adding to my code instruction before you need to also
python3 chatgpt.py
I hope this helps.
Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack
@ssadvisor Yes the module was installed and I even ran the install again (attaching image). And I've saved the file a million times - maybe I just moved it again before I screenshot it. This is extremely frustrating especially for beginners, because just like everything you learn from the ground up, you kind've need a bit more show and tell. I followed every single instructions step by step. When it didn't work you told me to do all these extra things that were not mentioned at all. And after I did them, it still didn't work. Is there any way Hassan can help me. Or maybe record a walkthrough. If someone doesn't show us visually what we're doing wrong, how to troubleshoot and how to fix things, how are we supposed to learn and improve and move forward...
@admin yes multiple times, but got the same error. So I just deleted Visual Studio Code and the folder I was working with, reinstalled it and it's working now. Hopefully I won't have to do this again.
@monika-mileva When you reinstalled visual studio code did you do anything different than the first time? Just so we can know what was the problem and maybe help others if they faced the same problem.
@husein no I didn't. I followed the same steps on the lesson.