0

Problem to import module

Hi, I am lost about something that never happen before... It's about importing modules. >>>import numpy as np ModuleNotFoundError: No module named 'numpy' >>>import nltk ModuleNotFoundError: No module named 'nltk' Does someone has an easy way to correct this ?

2nd Mar 2021, 9:46 AM
Quorin Coln
Quorin Coln - avatar
12 Answers
+ 2
I found the solution thank you Slick for your answer. The problem was my old pip version. $ python3.9 -m pip install --upgrade pip $ pip3.9 install numpy $ pip3.9 install nltk
2nd Mar 2021, 10:03 AM
Quorin Coln
Quorin Coln - avatar
+ 1
yeah, go to the command line and type: pip install numpy where are you doing this btw?
2nd Mar 2021, 9:49 AM
Slick
Slick - avatar
+ 1
Okay, i don't work with it. I'd start here though: https://pypi.org/project/tensorflow/#data
2nd Mar 2021, 11:41 AM
Slick
Slick - avatar
0
Among other I have the same problem with tensorflow.. but, "$ pip3.9 install tensorflow" doesn't work. >>>import tensorflow as tf ModuleNotFoundError: No module named 'tensorflow' Help please 🙏
2nd Mar 2021, 10:52 AM
Quorin Coln
Quorin Coln - avatar
0
im still not sure where you're doing this, but: pip install tensorflow is the command
2nd Mar 2021, 10:55 AM
Slick
Slick - avatar
0
Ok tensorflow is successfully installed. >>> import os >>> print(os.getcwd()) /Users/Groguu/Desktop/Python2021/chatBot That is where I am with my IDLE Shell 3.9.2
2nd Mar 2021, 11:15 AM
Quorin Coln
Quorin Coln - avatar
0
Cool stuff
2nd Mar 2021, 11:34 AM
Slick
Slick - avatar
0
Thanks Slick, just I still can't >>> import tensorflow
2nd Mar 2021, 11:40 AM
Quorin Coln
Quorin Coln - avatar
0
I think it can't works on python3.9 for the moment it's only usable with python3.8 max. In that case could you tell me what code I have to write in order to change the version of python. So if I can switch to version 3.8 maybe it will work đŸ€”
2nd Mar 2021, 11:49 AM
Quorin Coln
Quorin Coln - avatar
0
All you'd have to do is go to the python website and download the older version of python. Then, in your code, add a she bang (#!) with the path to whatever version of python you want to use and the code will run default with that version of python
2nd Mar 2021, 11:52 AM
Slick
Slick - avatar
0
Ok super 👌Do I have to understand that my code can contain different versions of python ? I mean, if I have a program, does this program could work by using different versions of python running in the same time ?
2nd Mar 2021, 12:05 PM
Quorin Coln
Quorin Coln - avatar
0
Sadly not at the same time... unless you make different modules that use different versions of python. Most are pretty portable since 2.7. But that version and before requires some modification to make it work with python 3.x.
2nd Mar 2021, 12:37 PM
Slick
Slick - avatar