0
votes

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.

2
every version has own folder with modules and you have to install modules in every version separatelly. Sometime module from one version may not work with other version. On Linux Python creates pip3.7 and pip3.6 to install modules in different version. Or you can use python3.7 -m pip install ... and python3.6 -m pip install ...furas

2 Answers

1
votes

Try to install numpy specifically for python3.6:

python3.6 -m pip install numpy

1
votes

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.