Categories
Python Answers

How to fix pip install failing with: OSError: [Errno 13] Permission denied on directory with Python?

Spread the love

To fix pip install failing with: OSError: [Errno 13] Permission denied on directory with Python, we can create a virtualenv in a folder where we have permission to write files.

To do this, we run

virtualenv venv
source venv/bin/activate
pip install -r requirements.txt

where venv is a folder that we can write files to.

And then we activate the virtualenv with

source venv/bin/activate

And then we install the packages into the virtualenv with

pip install -r requirements.txt

We can also install the packages into our home directory with

pip install --user -r requirements.txt

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *