Reputation: 11
I've been coding in Python 3.7.2 as my usual, but an API that I really want for my code only supports up to 3.6 (and does not support 2.7). I downloaded Python 3.6.4 to my computer, which also downloads a separate instance of the IDLE (not a problem). If I try to import something like numpy to my code in 3.7 (ex. import numpy as np) then it works as expected. However, if I do the same in the 3.6 IDLE I get:
Traceback (most recent call last): File "", line 1, in import numpy as np ModuleNotFoundError: No module named 'numpy'
I think that it's a path problem but I'm unsure on how to fix it, and I can't find a solution to this problem elsewhere. Any help is appreciated, thanks.
Upvotes: 0
Views: 106
Reputation: 1227
Step 1: Get the location of the python executable from IDLE
import sys
print(sys.executable) # e.g. /Users/jk/.../bin/python
Step 2: Run the pip
in the same folder as the one returned above.
/Users/jk/.../bin/pip install numpy
P.S. It's better to maintain libraries independently for each distribution, or even better use virtualenv
or conda
to create environments.
Upvotes: 1
Reputation: 124
Try to install numpy specifically for python3.6:
python3.6 -m pip install numpy
Upvotes: 1