Python Pipenv Install: EnvironmentError: Permission Denied

Viewed 2111

Trying to install python-decouple inside a pipenv shell:

(projectname) username@host: pipenv install python-decouple

But I'm getting this following error:

Installing python-decouple…
Error:  An error occurred while installing python-decouple!
Error text: Processing /home/username/.cache/pipenv/wheels/6d/5a/2d/acfg...422fd/python_decouple-3.3-py3-none-any.whl
Installing collected packages: python-decouple

ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/home/username/.local/share/virtualenvs/projectname-J2Y6DseW/lib/python3.6/site-packages/__pycache__/decouple.cpython-36.pyc'
Consider using the `--user` option or check the permissions.

I realize that I can install this package from outside the pipenv shell using:

python3 -m pip install --user python-decouple

But this would mean that this dependency wouldn't be managed by Pipenv when someone tries to replicate my project environment using Pipenv...

How can I get around this issue and what is the reason for it, what kind of permissions could I set on the file to overcome it?

2 Answers

Use it at your own risk:

The following solution works:

Run:

sudo chmod 777 /home/username/.local/share/virtualenvs/projectname-J2Y6DseW/lib/python3.6/site-packages/__pycache__

After this, try installing with pipenv again from within the pipenv shell.

I don't know whether this is a good solution or not, so please correct me if you have a better solution.

Just my two cents here:

I would modify the requirements.txt (every virtual environment should have one, or at least setup one for maintaining dependencies), by adding package for python-decouple. The current version is 3.3, so add this somewhere in the file: python-decouple==3.3 and re-run the virtual environment or install requirements.txt again.

See this link for more information on this package.

Related