0
votes

My Mac computer has Python 3.6 and Python 2.7 and I have successfully installed the basic modules such as numpy, scipy and matplotlib, for example, by doing the routine pip install and pip3 install. My Python 3.6 works totally well in Anaconda-Jupiter-Notebook, IDLE and Terminal, while Python 2.7 works only in terminal but not in IDLE.

Terminal - OK

enter image description here

Then for version check I tried

pip --version

Returning: pip 10.0.1 from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip (python 2.7)

pip3 --version

Returning: pip 10.0.1 from /Users/son520804/anaconda3/lib/python3.6/site-packages/pip (python 3.6)

Then,

which python2

Returning: /Library/Frameworks/Python.framework/Versions/2.7/bin/python2

which pip2

Returning: /Library/Frameworks/Python.framework/Versions/2.7/bin/pip2

How could I resolve this issue and enable the Python 2.7 idle to import the modules? Much appreciated for your help.

2
Try installing packages with setup.py. Here is how: stackoverflow.com/questions/1471994/what-is-setup-py - Peppa

2 Answers

1
votes
find / -iname '*numpy*'

This is a terminal operation not a python command, you can try running that in the terminal to see where it's storing numpy, but you'll probably get the python3's version.

Try:

pip2 uninstall numpy

Then:

pip2 install numpy

It might be due to your machine seeing python3 as your default "python" so pip might actually be installing it again to python3. By denoting pip2 it should be linked to python2 (might actually need to do 'pip2.7'). Hope it helps!

1
votes

Perhaps your pip is an alias to pip3. Find it out by pip --version and if so install packages for python 2.7 as pip2.7 install matplotlib