OSError: [Errno 1] Operation not permitted:

前端 未结 1 845
野趣味
野趣味 2021-01-26 12:44

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:

相关标签:
1条回答
  • 2021-01-26 13:37

    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 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.

    0 讨论(0)
提交回复
热议问题