使用 pip 安装 NumPy 时出现异常错误
Exception Error when Installing NumPy with pip
我一直在尝试安装 NumPy,但经历了一段残酷的时光。无论我尝试什么,我都会不断收到异常错误。我使用了命令
$pip install numpy
但是它抛出了这个错误
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-6.1.1-py2.7.egg/pip/basecommand.py", line 246, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-6.1.1-py2.7.egg/pip/commands/install.py", line 352, in run
root=options.root_path,
File "/Library/Python/2.7/site-packages/pip-6.1.1-py2.7.egg/pip/req/req_set.py", line 693, in install
**kwargs
File "/Library/Python/2.7/site-packages/pip-6.1.1-py2.7.egg/pip/req/req_install.py", line 817, in install
self.move_wheel_files(self.source_dir, root=root)
File "/Library/Python/2.7/site-packages/pip-6.1.1-py2.7.egg/pip/req/req_install.py", line 1018, in move_wheel_files
isolated=self.isolated,
File "/Library/Python/2.7/site-packages/pip-6.1.1-py2.7.egg/pip/wheel.py", line 269, in move_wheel_files
clobber(source, dest, False, fixer=fixer, filter=filter)
File "/Library/Python/2.7/site-packages/pip-6.1.1-py2.7.egg/pip/wheel.py", line 215, in clobber
shutil.copyfile(srcfile, destfile)
File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 83, in copyfile
with open(dst, 'wb') as fdst:
IOError: [Errno 13] Permission denied: '/usr/local/man/man1/nosetests.1'
只是为了检查,我在 Python 中使用了 import 来查看它是否有任何东西,但它也抛出了一个错误。我不知道发生了什么。
$pip install scipy
没问题。任何帮助表示赞赏!我似乎找不到任何关于如何解决这个问题的信息。
谢谢!
Homebrew tries to leave /usr/local writable, so you don't need sudo
. See the FAQ for details.
但是,如果您不小心使用了一次 sudo
— 或者如果您 运行 将一些其他安装程序安装到 /usr/local
中,但没有意识到您想要它是 Homebrew 风格的 — 那么当你的 Homebrew 东西试图修改用 sudo
.
保存的文件时,你会开始出错
如果您尝试同时使用 Apple 预装的 Python 2.7 和 Homebrew Python 2.7,则会出现一个特殊问题:它们都想将脚本安装到 /usr/local/bin
,手册页到 /usr/local/man
,等等。Apple 想要使用 sudo。
因此,很可能您过去为 Apple 的 Python 做了 sudo pip install nose
,现在 pip install nose
为 Homebrew 的 Python 正试图覆盖它的文件和没有权限这样做。 (或者可能不是 nose
本身,而是在你没有意识到的情况下需要 nose
的其他东西。)
在 Homebrew Python 中使用 sudo
只会让问题变得更糟;不要那样做。
正确的解决方案是:
- 不使用第三方 Python 2.7、Homebrew 或其他,坚持使用 Apple 的(或升级到 Python 3;这样通常不会与 Apple 的 2.7 冲突……),或者
- 永远不要碰 Apple 的 Python 2.7,只使用另一个。
但在这一点上,你已经把事情搞砸了,我怀疑你想从头开始重新安装你的 OS,对吧?
对于前者,您可以通过 brew uninstall python
来解决问题,对于后者,您可以通过卸载使用 Apple 的 Python 安装的所有内容来解决问题。 (你不能卸载 Apple 的 Python;那会破坏 OS,而下一个 OS 更新无论如何都会撤消它......)然后,无论哪种方式,你可能想要为了安全起见,重新安装您选择使用的 Python 所需的每个软件包。
或者,对于一个快速而肮脏的解决方案,每次出现这样的错误时,您可以删除冲突文件 (sudo rm /usr/local/man/man1/nosetests.1
) 或使其可覆盖 (sudo chmod a+w /usr/local/man/man1/nosetests.1
);然后,您的 pip
将起作用。直到下一个错误,你可以用同样的方法修复。
只需 运行 cmd 作为管理员就可以了。
我一直在尝试安装 NumPy,但经历了一段残酷的时光。无论我尝试什么,我都会不断收到异常错误。我使用了命令
$pip install numpy
但是它抛出了这个错误
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-6.1.1-py2.7.egg/pip/basecommand.py", line 246, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-6.1.1-py2.7.egg/pip/commands/install.py", line 352, in run
root=options.root_path,
File "/Library/Python/2.7/site-packages/pip-6.1.1-py2.7.egg/pip/req/req_set.py", line 693, in install
**kwargs
File "/Library/Python/2.7/site-packages/pip-6.1.1-py2.7.egg/pip/req/req_install.py", line 817, in install
self.move_wheel_files(self.source_dir, root=root)
File "/Library/Python/2.7/site-packages/pip-6.1.1-py2.7.egg/pip/req/req_install.py", line 1018, in move_wheel_files
isolated=self.isolated,
File "/Library/Python/2.7/site-packages/pip-6.1.1-py2.7.egg/pip/wheel.py", line 269, in move_wheel_files
clobber(source, dest, False, fixer=fixer, filter=filter)
File "/Library/Python/2.7/site-packages/pip-6.1.1-py2.7.egg/pip/wheel.py", line 215, in clobber
shutil.copyfile(srcfile, destfile)
File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 83, in copyfile
with open(dst, 'wb') as fdst:
IOError: [Errno 13] Permission denied: '/usr/local/man/man1/nosetests.1'
只是为了检查,我在 Python 中使用了 import 来查看它是否有任何东西,但它也抛出了一个错误。我不知道发生了什么。
$pip install scipy
没问题。任何帮助表示赞赏!我似乎找不到任何关于如何解决这个问题的信息。
谢谢!
Homebrew tries to leave /usr/local writable, so you don't need sudo
. See the FAQ for details.
但是,如果您不小心使用了一次 sudo
— 或者如果您 运行 将一些其他安装程序安装到 /usr/local
中,但没有意识到您想要它是 Homebrew 风格的 — 那么当你的 Homebrew 东西试图修改用 sudo
.
如果您尝试同时使用 Apple 预装的 Python 2.7 和 Homebrew Python 2.7,则会出现一个特殊问题:它们都想将脚本安装到 /usr/local/bin
,手册页到 /usr/local/man
,等等。Apple 想要使用 sudo。
因此,很可能您过去为 Apple 的 Python 做了 sudo pip install nose
,现在 pip install nose
为 Homebrew 的 Python 正试图覆盖它的文件和没有权限这样做。 (或者可能不是 nose
本身,而是在你没有意识到的情况下需要 nose
的其他东西。)
在 Homebrew Python 中使用 sudo
只会让问题变得更糟;不要那样做。
正确的解决方案是:
- 不使用第三方 Python 2.7、Homebrew 或其他,坚持使用 Apple 的(或升级到 Python 3;这样通常不会与 Apple 的 2.7 冲突……),或者
- 永远不要碰 Apple 的 Python 2.7,只使用另一个。
但在这一点上,你已经把事情搞砸了,我怀疑你想从头开始重新安装你的 OS,对吧?
对于前者,您可以通过 brew uninstall python
来解决问题,对于后者,您可以通过卸载使用 Apple 的 Python 安装的所有内容来解决问题。 (你不能卸载 Apple 的 Python;那会破坏 OS,而下一个 OS 更新无论如何都会撤消它......)然后,无论哪种方式,你可能想要为了安全起见,重新安装您选择使用的 Python 所需的每个软件包。
或者,对于一个快速而肮脏的解决方案,每次出现这样的错误时,您可以删除冲突文件 (sudo rm /usr/local/man/man1/nosetests.1
) 或使其可覆盖 (sudo chmod a+w /usr/local/man/man1/nosetests.1
);然后,您的 pip
将起作用。直到下一个错误,你可以用同样的方法修复。
只需 运行 cmd 作为管理员就可以了。