2

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?

itsafox
  • 71
  • 2
  • 5

2 Answers2

1

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.

itsafox
  • 71
  • 2
  • 5
0

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.

de_classified
  • 1,927
  • 1
  • 15
  • 19
  • Generated a requirements.txt from the Pipfile, added python-decouple==3.3 and then tried to regenerate the Pipfile from the requirements.txt. Receiving the exact same error... Thank you for your suggestion though! – itsafox Jul 16 '20 at 00:23
  • Try doing this inside of the virtualenv i.e within the `(projectname)` environment, `pip install python-decouple`. If you receive any error related to `pip` then update the `pip` package with `upgrade` command. – de_classified Jul 16 '20 at 00:41
  • Just tried this... It's giving me the exact same error. – itsafox Jul 16 '20 at 02:46