简体   繁体   中英

python - ImportError: No module named scipy on Mac

It's been so hard to find solution for this problem.

I've been reading on the internet and found this questions on Stackoverflow:

Solution #1 and Solution #2 with no results.

When I use:

pip install scipy

It outputs

Requirement already satisfied (use --upgrade to upgrade): scipy in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python

Then I do

pip install scipy --updrage

And it outputs

OSError: [Errno 1] Operation not permitted: 
'/var/folders/y3/r_j97_g91494mm7r9th0zycm0000gn/T/pip-paR57c-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy-1.8.0rc1-py2.7.egg-info'

I even try to install using port :

sudo port install py27-numpy py27-scipy py27-matplotlib py27-ipython +notebook py27-pandas py27-sympy py27-nose

Same result, it says it's been installed but when I try to run my Python project, prints the same error.

Hope you guys can help me.

I believe that your issue may be how you are running your code - OS-X can have both the system python and a user python installation.

From the command prompt, (the same one that pip tells you that you already have scipy installed), try running your script, which I will assume is called your_script.py with:

python your_script.py

And it should work, however if you run:

your_script.py

it may not work.

I don't have a Mac to experiment on but you should do some reading on this issue online - here

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM