1

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!

6
  • 1
    It looks like it tries to install globally, so you need permissions for that, or use virtualenv to create virtual storage where you can install numpy without problem. Exactly in your case it says it cannot copy file to /usr/local/man/man1/nosetests.1 Commented Apr 22, 2015 at 20:04
  • Okay. How would I get the permissions for it? Would sudo do the right thing? I should also mention, when I tried running pip again, it told me that numpy was already installed and up to date. Commented Apr 22, 2015 at 20:08
  • Yes, sudo may help you. Or, if you don't need it globally, try to create a virtualenv Commented Apr 22, 2015 at 20:09
  • Trying to run it with sudo tells me the same as the when I ran it the second time, that it is already installed and up to date. I do need it globally. Commented Apr 22, 2015 at 20:11
  • Try pip uninstall numpy and sudo install numpy after them. Commented Apr 22, 2015 at 20:12

2 Answers 2

6

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.

Sign up to request clarification or add additional context in comments.

12 Comments

Okay. Is there an easy way to clean all my added stuff up and go to scratch without a rebuild? Most stuff I need is fairly organized, so a rebuild wouldn't be the end of the world. I am guessing that just from trying to load different packages from different sources I have created problems all over the place. What's the easiest way to get back to scratch? Thanks!
@Grimey: Which way do you want to end up? Apple site-packages and no Homebrew, or Homebrew site-packages and empty Apple site-packages? The first one is simpler, but if it's not the one you want, that doesn't help… Also, have you ever installed any packages without pip (or do you not know the answer to that)?
I have certainly tried to install packages. I am still quite new to Python, so I have tried installing packages in a plethora of different ways. In retrospect, should have read more into it. It seems to me that homebrew is useful and has many useful packages. Maybe this would be the best way to go? Which would you suggest? I am pretty indifferent.
First, for installing programs and shared libraries, Homebrew is definitely the way to go, even if you don't use it for Python itself. As for which Python to use… well, I'd say learn Python 3, then leave Apple's as the only 2.7, which you rarely use, and install 3.4 from python.org or Homebrew. If you can't do that, I personally think it's easier to stick with Apple's Python 2.7, but a lot of people disagree. (I wrote a blog post a couple years ago explaining why.)
@Grimey: Or, since you're looking to install NumPy and SciPy… have you looked into using one of the scientific distributions of Python+extras, like Enthought or PythonXY? (Maybe not those two in particular–I think the first is non-free and the second doesn't yet work on Mac—but there are others.) That would get you not just NumPy and SciPy, but also Qt (which is much more painful to set up) and other things, and some of them have self-contained package management…
|
-3

Just run cmd as Admin it worked for me.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.