Skip to content

Forum in maintenance, we will back soon 🙂

Connecting OpenAI m...
 
Notifications
Clear all

Connecting OpenAI module

11 Posts
4 Users
2 Reactions
16 Views
(@monika-mileva)
Posts: 6
Active Member Customer
Topic starter
 

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.

 

 

 
Posted : 06/01/2024 12:09 pm
SSAdvisor
(@ssadvisor)
Posts: 1139
Noble Member
 

@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

 
Posted : 06/01/2024 12:25 pm
(@monika-mileva)
Posts: 6
Active Member Customer
Topic starter
 

@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.

 
Posted : 06/01/2024 12:44 pm
SSAdvisor
(@ssadvisor)
Posts: 1139
Noble Member
 

@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

 
Posted : 06/01/2024 7:30 pm
(@monika-mileva)
Posts: 6
Active Member Customer
Topic starter
 

@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.

This post was modified 7 months ago by Monika Mileva
 
Posted : 06/01/2024 8:28 pm
SSAdvisor
(@ssadvisor)
Posts: 1139
Noble Member
 

@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

 
Posted : 06/01/2024 10:51 pm
(@monika-mileva)
Posts: 6
Active Member Customer
Topic starter
 

@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...

 
Posted : 06/01/2024 11:33 pm
Hasan Aboul Hasan
(@admin)
Posts: 1276
Member Admin
 

@monika-mileva Hi, did you try restarting VS code?

 
Posted : 06/02/2024 9:35 am
(@monika-mileva)
Posts: 6
Active Member Customer
Topic starter
 

@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.

 
Posted : 06/03/2024 2:39 am
(@husein)
Posts: 550
Member Moderator
 

@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.

 
Posted : 06/03/2024 12:45 pm
(@monika-mileva)
Posts: 6
Active Member Customer
Topic starter
 

@husein no I didn't. I followed the same steps on the lesson.

 
Posted : 06/03/2024 3:06 pm
Share:
[the_ad_group id="312"]