使用pip安装NumPy时出现异常错误

Gri*_*mey 0 python installation numpy pip

我一直在尝试安装NumPy,并且已经有了残酷的时间.无论我尝试什么,我都会收到异常错误.我用了这个命令

$pip install numpy
Run Code Online (Sandbox Code Playgroud)

但它抛出了这个错误

    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'
Run Code Online (Sandbox Code Playgroud)

只是为了检查,我在Python中使用import来查看它是否有任何东西,但它也引发了错误.我不知道发生了什么事.

$pip install scipy
Run Code Online (Sandbox Code Playgroud)

没有给我任何问题.任何帮助表示赞赏!我似乎找不到任何关于如何解决这个问题.

谢谢!

aba*_*ert 6

Homebrew试图离开/ usr/local writeable,所以你不需要sudo.有关详细信息,请参阅FAQ.

但是,如果您不小心使用了sudo一次 - 或者如果您运行的某些其他安装程序安装了/usr/local那些没有意识到您想要它的Homebrew风格 - 那么当您的Homebrew东西尝试修改保存的文件时,您将开始收到错误sudo.

如果您尝试使用Apple预安装的Python 2.7和Homebrew Python 2.7,则会出现一个特殊问题:他们都想安装脚本/usr/local/bin,手册页/usr/local/man等等.而且Apple想要使用sudo.

所以,很可能,你sudo pip install nose过去曾为Apple的Python 做过,现在pip install noseHomebrew的Python试图覆盖它的文件并且没有权限这样做.(或者可能不是nose它自己,但是在nose没有你意识到的情况下需要其他东西.)

使用sudoHomebrew Python会让问题变得更糟; 不要那样做.

正确的解决方案是:

  • 不使用第三方Python 2.7,Homebrew或其他,只需坚持使用Apple(或升级到Python 3;然后通常与Apple的2.7没有冲突......),或者
  • 永远不要触摸Apple的Python 2.7,只使用另一个.

但是在这一点上,你已经搞砸了,我怀疑你想从头开始重新安装你的操作系统,对吧?

您可以brew uninstall python为前者解决问题,或者卸载使用Apple的Python安装的所有内容.(你无法卸载Apple的Python;这会破坏操作系统,下一次操作系统更新无论如何都会撤消它...)然后,无论如何,你可能想要重新安装你选择的任何Python所需的每个软件包.一起去,为了安全.

或者,对于快速和脏的解决方案,每次出现这样的错误时,您可以删除冲突的文件(sudo rm /usr/local/man/man1/nosetests.1)或使其可覆盖(sudo chmod a+w /usr/local/man/man1/nosetests.1); 然后,你的pip意志工作.直到下一个错误,你可以用同样的方式修复.