OSError: [Errno 1] Operation not permitted:

2019-03-06 07:35发布

I am facing some serious resistance with pandas and specifically numpy. When I try to run my current python program, I receive the following message:

ImportError: this version of pandas is incompatible with numpy < 1.9.0
your numpy version is 1.8.0rc1.
Please upgrade numpy to >= 1.9.0 to use this pandas version

I tried to upgrade numpy with:

pip install --upgrade --force-reinstall numpy

But then I receive the following error:

OSError: [Errno 1] Operation not permitted:
'/var/folders/jh/xdhjqn1x3f32tt0s0yqyh0dm0000gn/T/pip-mqbUP3-
uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy-1.8.0rc1-py2.7.egg-info'

Based off of what I have seen and read online, I really am not positive what the issue is.

1条回答
乱世女痞
2楼-- · 2019-03-06 08:05

I assume you are on macOS (otherwise, the --user flag, or running with sudo, should solve the issue).

The issue is likely that you are trying to upgrade the same Python that macOS uses for its internal operations. Mac is concerned that ignorant users will delete Python and destabilize their OS, so, they put /usr/bin/python in a "wheel" directory that you will not be able to touch (even with sudo).

To confirm this is the problem, try this:

  1. Open terminal and type which Python. You'll probably get something like /usr/bin/python.
  2. Type ls -l /usr/bin/python, where you use the path from step 1. The output will look like -rwxr-xr-x 1 root wheel 66880 Sep 21 00:35 /usr/bin/python

See how it says "wheel"? Wheel is a super-protected group that you can't touch, even with sudo.

To get around this, one option is to install a new copy of Python somewhere else. Personally, I hate having multiple copies of the same software, so I force would force it to upgrade like this:

  1. Reboot the computer in recovery mode
  2. Find the terminal and type csrutil disable
  3. Reboot normally, then upgrade numpy with pip2 `install --user --upgrade numpy
  4. Repeat steps a and b, this time changing "disable" to "enable"

Note: "csrutil disable" is serious business that can destabilize your machine, I would use it only when absolutely necessary and re-enable it ASAP. But AFAIK it's the only way to upgrade Python packages in a wheel directory.

查看更多
登录 后发表回答