Reputation: 43
My system is Mac OS X. I first installed numpy through macport and then download Pycharm and find that whatever interpreter I choose I cannot import numpy. The results are as follows:
/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 "/Users/erleye/Documents/Python/Pycharm Projects/test.py"
Traceback (most recent call last):
File "/Users/erleye/Documents/Python/Pycharm Projects/test.py", line 4, in <module>
import numpy as np
ImportError: No module named numpy
But if I use python test.py
in the terminal it works fine.
When I type which -a python
in terminal, i have:
/opt/local/bin/python
/opt/local/bin/python
/Library/Frameworks/Python.framework/Versions/2.7/bin/python
/usr/local/bin/python
/usr/bin/python
/opt/local/bin/python
I don't know why I have so many versions of python, but I am sure when I chose interpreter in Pycharm, it is the one that has numpy installed. What can I do?
Upvotes: 4
Views: 10987
Reputation: 365597
I don't know why I have so many versions of python, but I am sure when I chose interpreter in Pycharm, it is the one that has numpy installed.
No it isn't.
According to your which
, the Python that gets run when you type python python.py
at the terminal is going to be /opt/local/bin/python
, the MacPorts one.
But according to the error message in PyCharm, the Python that it's running is /Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
, which is not the MacPorts one. (It's probably from a binary installer from Python.org.)
So, that's your problem.
Well, it's just barely possible that you're running the MacPorts Python, but you've somehow set a PYTHONPATH
or PYTHONHOME
to force it to try to use the Python.org site-packages instead of its own. But in that case, you've got even bigger problems…
Of course your bigger problem is that you have 3 different copies of Python 2.7, and a total of 6 path entires for them, and you don't even know how you got them or which ones' site-packages you're installing into. It would probably be easier to clean things up than to keep trying to muddle through, but it's your choice.
Upvotes: 2