2

I just got a new macbook running MacOS 10.14.1 and am attempting to install pip. I'm on the admin user account. When attempting to install pip, I get the error below.

Prior to this, I sudo installed pip via sudo easy_install pip, but started reading that this is potentially harmful, so did sudo uninstall pip.

There's been other answers (pip is not able to install packages correctly: Permission denied error) exploring the solution, but I'm more interested in why I don't have permissions to this folder, and fixing the underlying root cause. After excessive googling for the last hour I'm contemplating doing a clean install, as installing pip via sudo may have messed with root packages.

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

Note, I also get this error when trying to install pip directly.

➜  ~ 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.
John M.
  • 323
  • 2
  • 5
  • 13
  • 1
    Try `python get-pip.py --user`, however, IMO there's little harm in installing `pip` on MacOS via `sudo easy_install pip`. What's dangerous is installing arbitrary packages with `sudo` afterwards, e.g. `sudo pip install somepkg`. Resort to `pip install somepkg --user` and you'll be safe. – hoefling Jan 16 '19 at 09:54
  • 1
    *why I don't have permissions* Because users don't have permissions to system folders, only root has. – phd Jan 16 '19 at 16:59

0 Answers0