尝试安装pip时权限被拒绝-[Errno 13]权限被拒绝:'/ Library / Python / 2.7 / site-packages / test-easy-install-60057.pth'

时间:2019-01-16 06:49:53

标签: python pip

我刚得到一台运行MacOS 10.14.1的新Macbook,正在尝试安装pip。我使用的是admin用户帐户。尝试安装pip时,出现以下错误。

在此之前,我通过sudo easy_install pip sudo安装了pip,但开始读到这可能有害,sudo uninstall pip也是如此。

还有其他答案(pip is not able to install packages correctly: Permission denied error)探索该解决方案,但是我对为什么没有此文件夹的权限并解决根本的根本原因更感兴趣。在过去一个小时的大量谷歌搜索之后,我正在考虑进行全新安装,因为通过sudo安装pip可能会与根软件包混淆。

➜  ~ easy_install pip
error: can't create or remove files in install directory

The following error occurred while trying to add or remove files in the
installation directory:

    [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/test-easy-install-60057.pth'

The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

    /Library/Python/2.7/site-packages/

Perhaps your account does not have write access to this directory?  If the
installation directory is a system-owned directory, you may need to sign in
as the administrator or "root" account.  If you do not have administrative
access to this machine, you may wish to choose a different installation
directory, preferably one that is listed in your PYTHONPATH environment
variable.

For information on other options, you may wish to consult the
documentation at:

  https://pythonhosted.org/setuptools/easy_install.html

Please make the appropriate changes for your system and try again.

请注意,尝试直接安装pip时也会出现此错误。

➜  ~ python get-pip.py
Collecting pip
  Downloading https://files.pythonhosted.org/packages/c2/d7/90f34cb0d83a6c5631cf71dfe64cc1054598c843a92b400e55675cc2ac37/pip-18.1-py2.py3-none-any.whl (1.3MB)
    100% |████████████████████████████████| 1.3MB 9.7MB/s
Collecting wheel
  Downloading https://files.pythonhosted.org/packages/ff/47/1dfa4795e24fd6f93d5d58602dd716c3f101cfd5a77cd9acbe519b44a0a9/wheel-0.32.3-py2.py3-none-any.whl
Installing collected packages: pip, wheel
Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/pip'
Consider using the `--user` option or check the permissions.

0 个答案:

没有答案