I recently upgraded to OSX Sierra, and now I can't import any packages in Python. When I run a standard import numpy
in the python console (I'm using Pycharm) I get
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
ImportError: No module named numpy
I think the problem's coming from when I reinstalled my ports when I was migrating macports, according to the instructions here . I'm pretty sure everything was working in python after I'd upgraded to Sierra, but broke once I did this.
My first thought was to reinstall numpy, but when I go to the command line and run pip install numpy
, I get
Requirement already satisfied: numpy in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python.
However, running which numpy
turns up nothing, which seems weird, since it just told me that numpy's installed, and I can find it on my computer if I use easyfind. Since it might be relevant, which python
gives me /opt/local/bin/python
.
I've tried a few different fixes, but haven't been able to get anything to work so far. I have a feeling that I'm missing something very basic, but can't figure out what it is. I'm running python 2.7.12 on mac 10.12.1.
In my PyCharm I use virtual environments. An upgrade to Sierra may have, as you suggested, removed the Python port and thus your virtual environment may need to be recreated too.
Not exactly solving the original problem, but I did figure out how to work around it. I just installed python 3.3 (via macports) and set it to be the default python of my computer, and then reinstalled Pycharm (although I probably could have just restored settings to their defaults). Everything seems to be working now, in python 3.3, although I do have to use pip as python3.3 -m pip install
rather than the standard pip install
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.