python找不到numpy

时间:2015-05-07 11:31:34

标签: python python-2.7 numpy

我试图按照此链接中的说明操作:http://www.thisisthegreenroom.com/2011/installing-python-numpy-scipy-matplotlib-and-ipython-on-lion/ 但是,似乎我的python找不到Numpy,Scipy以及我用pip安装的所有内容。

现在,当我键入哪个python时,它会显示 / usr / local / bin / python 。 但是,当我输入

  pip install numpy

显示

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

因此它们似乎位于不同的目录中,可能我先前安装了numpy,这使得pip一直告诉我它们已经安装好了。我想知道有什么方法吗?

更新,我试图导入它。

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

我还尝试卸载numpy并重新安装。但是,当我卸载它。它仍然给我错误。

    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'

3 个答案:

答案 0 :(得分:2)

似乎您正在使用的pip版本使用的是默认的mac系统范围的python解释器/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python,而不是/usr/local/bin中安装的版本。

在我开始使用homebrew之前,我几乎遇到过相同的问题。我建议您在brew and python上查看此页面。您可能需要删除pip并从brew重新安装。{1}}。顺便说一句,使用brew,不需要sudo

答案 1 :(得分:0)

尝试:pip uninstall numpy

然后:pip install numpy

...并尝试使用sudo: sudo pip install numpy

答案 2 :(得分:0)

首先,您应该使用pip list检查是否安装了numpy。

如果您已经安装,请检查您的程序IDE是否pycharm,并检查pycharm解释器是否执行本地解释器或虚拟解释器。如果解释器是虚拟的,您应该更改为本地。如果有效,您可以选择本地解释器来创建新项目。

更多细节:https://www.jianshu.com/p/9c3507cca2b9

在我的问题中,我无法使用pip install -U scikit-learn更新scikit-learn,并出现问题

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.

它也出现在你的错误中。所以,我找到了你的问题。

我尝试了商品pip install -U --ignore-installed scikit-learn,它解决了我的问题。