3

I was trying to follow the instruction from this link :http://www.thisisthegreenroom.com/2011/installing-python-numpy-scipy-matplotlib-and-ipython-on-lion/ However, it seems my python can not find the Numpy, Scipy and everything I install using pip.

Right now, when I type which python, it shows /usr/local/bin/python. However, when I type

  pip install numpy

it shows

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

Thus it seems they are in different directory, and probably I installed numpy previously, which makes pip keep telling me they are installed. I wonder is there any way around that ?

update, I have tried to import it.

    import numpy
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    ImportError: No module named numpy

I have also tried to uninstall the numpy and install it again. However, when I uninstall it. It still gives me error.

    applematoMacBook-Air:~ apple$ pip uninstall numpy
    DEPRECATION: Uninstalling a distutils installed project (numpy) has been     deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
    Uninstalling numpy-1.8.0rc1:
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy-1.8.0rc1-py2.7.egg-info
    Proceed (y/n)? y
    Exception:
    Traceback (most recent call last):
    File "/usr/local/lib/python2.7/site-packages/pip-6.1.1-py2.7.egg/pip/basecommand.py", line 246, in main
    status = self.run(options, args)
    File "/usr/local/lib/python2.7/site-packages/pip-6.1.1-py2.7.egg/pip/commands/uninstall.py", line 70, in run
    requirement_set.uninstall(auto_confirm=options.yes)
    File "/usr/local/lib/python2.7/site-packages/pip-6.1.1-py2.7.egg/pip/req/req_set.py", line 274, in uninstall
    req.uninstall(auto_confirm=auto_confirm)
    File "/usr/local/lib/python2.7/site-packages/pip-6.1.1-py2.7.egg/pip/req/req_install.py", line 730, in uninstall
  paths_to_remove.remove(auto_confirm)
    File "/usr/local/lib/python2.7/site-packages/pip-6.1.1-py2.7.egg/pip/req/req_uninstall.py", line 126, in remove
    renames(path, new_path)
    File "/usr/local/lib/python2.7/site-packages/pip-6.1.1-py2.7.egg/pip/utils/__init__.py", line 292, in renames
  shutil.move(old, new)
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move
    os.unlink(src)
  OSError: [Errno 13] Permission denied: '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy-1.8.0rc1-py2.7.egg-info'
11
  • 1
    for starters.. what Unix Version are you running Python on? Commented May 7, 2015 at 11:36
  • @OluDoug Sorry. I am running Python on the Mac OS 10.10 Commented May 7, 2015 at 11:39
  • 1
    Why do you think your python is not able to find it? How you tried to import it? Commented May 7, 2015 at 11:46
  • Yes, I have tried that. it gives me back this :Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named numpy Commented May 7, 2015 at 11:53
  • what does your sys.path return..? Commented May 7, 2015 at 11:56

3 Answers 3

2

Seems like the version of pip you are using is using the default mac system-wide python interpreter /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python instead of the one installed in /usr/local/bin.

I've pretty much experienced the same issues until I started using homebrew. I'd recommend to have a look at this page on brew and python. You'd might need to remove pip and reinstall it from brew. Btw, using brew, there's no need for sudo.

Sign up to request clarification or add additional context in comments.

4 Comments

As I followed the link, I used the homebrew to install the python. However, in the link I posted, he mentioned add export "PATH=/usr/local/bin:$PATH" to the .bash_profile . The link you just provided, says add "export PATH=/usr/local/bin:/usr/local/sbin:$PATH " to .profile. I tried your ways, when I re-install python in homebrew, it indicates "Warning: python-2.7.9 already installed, it's just not linked" . So do you think is there a way to fix this?
I think I fixed the issue... Even though I don't know exactly how or why. I basically uninstall the python from homebrew, and reinstall it, and install the pip again. Everything seems work file right now. Thank you.
The issue was the pip executable you've used earlier used the system-wide python interpreter. This means that all packages installed this way end up in the system's site-packages folder. If you fire up the brewed interpreter (also with its own site-packages folder), it does not have these packages available (although you could indicate that in the PYTHONPATH). By removing and reinstalling pip, the new pip version just uses the brewed python and its associated site-packages folder.
After brew install python2 , I can use python2 myapp.py but python command is still calling the system-wide installed python.
0

try: pip uninstall numpy

and then: pip install numpy

...and try it with sudo: sudo pip install numpy

1 Comment

I have tried your way. It still gives me error. I update on the up
0

first, you should use pip list to check out have you installed numpy .

if you already installed, check out your program IDE whether the pycharm, and check the pycharm interpreter does the local interpreter or virtual interpreter. if the interpreter is virtual, you should change to local. if it works, you can create the new project with select the local interpreter.

more detail: https://www.jianshu.com/p/9c3507cca2b9

in my problem, i can't update scikit-learn with pip install -U scikit-learn, and occur the problem

Cannot uninstall 'scikit-learn'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

it occured in your error too. so, i find your problem.

and i try the commod pip install -U --ignore-installed scikit-learn, and it solve my problem.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.