我试图按照此链接中的说明进行操作:http://www.thisisthegreenroom.com/2011/installing-python-numpy-scipy-matplotlib-and-ipython-on-lion/ 然而,我的 python 似乎找不到 Numpy、Scipy 和我使用 pip 安装的所有东西。
现在,当我输入 which 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'
最佳答案
似乎您正在使用的 pip
版本正在使用默认的 mac 系统级 python 解释器 /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
而不是安装在 /usr/local/bin
中的那个。
在我开始使用 homebrew 之前,我几乎遇到过同样的问题。 .我建议在 brew and python 上查看此页面.您可能需要删除 pip
并从 brew
重新安装它。顺便说一句,使用 brew
,不需要 sudo
。
关于python 找不到 numpy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30099823/