Could not install packages due to an EnvironmentError: [Errno 13] Pip install Pytest

Viewed 4535

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.

1 Answers

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

Related