简体   繁体   中英

Exception Error when Installing NumPy with pip

I have been trying to install NumPy and have been have a brutal time with it. I keep getting an exception error no matter what I try. I used the command

$pip install numpy

but it threw this error

    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'

Just to check, I used import in Python to see if it got anything, it also threw an error though. I have no idea what is going on.

$pip install scipy

gave me no problems. Any help is appreciated! I can't seem to find anything on how to fix this.

Thanks!

Homebrew tries to leave /usr/local writable, so you don't need sudo . See the FAQ for details.

However, if you accidentally use sudo once—or if some other installer you run installs stuff into /usr/local that doesn't realize you wanted it Homebrew-style—then you'll start getting errors, when your Homebrew stuff attempt to modify files that were saved with sudo .

There's a particular problem if you try to use both Apple's pre-installed Python 2.7 and a Homebrew Python 2.7: they both want to install scripts to /usr/local/bin , man pages to /usr/local/man , etc. And Apple's wants to use sudo.

So, most likely, you did a sudo pip install nose for Apple's Python in the past, and now pip install nose for Homebrew's Python is trying to overwrite its files and doesn't have permissions to do so. (Or maybe not nose itself, but something else that requires nose without you realizing it.)

Using sudo with the Homebrew Python will just make the problem worse; don't do that.

The right solution is to either:

  • Not use a third-party Python 2.7, Homebrew or otherwise, and just stick with Apple's (or upgrade to Python 3; then there's usually no conflict with Apple's 2.7…), or
  • Never touch Apple's Python 2.7, and only use the other one.

But at this point, you've already screwed things up, and I doubt you want to reinstall your OS from scratch, right?

You can fix things by brew uninstall python for the former, or by uninstalling everything you installed with Apple's Python for the latter. (You can't uninstall Apple's Python; that would break the OS, and the next OS update would just undo it anyway…) And then, either way, you'll probably want to reinstall every package you need for whichever Python you chose to go with, to be safe.

Or, for a quick&dirty solution, every time you get an error like this, you can either delete the conflicting file ( sudo rm /usr/local/man/man1/nosetests.1 ) or make it overwritable ( sudo chmod a+w /usr/local/man/man1/nosetests.1 ); then, your pip will work. Until the next error, which you can fix the same way.

只需以Admin身份运行cmd就可以了。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM