2

I am having issues when trying to set up pytest. When I run:

pip install pytest pytest-cache

I receive this error message:

Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/apipkg' Consider using the --user option or check the permissions.

Chloe
  • 21
  • 1
  • 2
  • Possible duplicate of [pip install -r: OSError: \[Errno 13\] Permission denied](https://stackoverflow.com/questions/31512422/pip-install-r-oserror-errno-13-permission-denied) – phd Jan 12 '19 at 17:00
  • https://stackoverflow.com/search?q=%5Bpip%5D+Could+not+install+packages+due+to+an+EnvironmentError%3A+Errno+13+Permission+denied – phd Jan 12 '19 at 17:00

1 Answers1

0

Based on the error message you do not have permission to install in the Library directory & you can use --user option to install it.

pip install pytest pytest-cache --user

$ pip install --help

--user    Install to the Python user install directory for your platform. Typically ~/.local/, or %APPDATA%\Python on Windows. (See the Python documentation for site.USER_BASE for
                              full details.)

Or if you have sudo access, you can use sudo to install in the Library directory

sudo pip install pytest pytest-cache.

An alternative & recommended approach is to use virtualenv

Amit
  • 19,780
  • 6
  • 46
  • 54