How to Avoid "Permission Denied" When Using Pip with Virtualenv

How to avoid Permission denied when using pip with virtualenv

virtualenv permission problems might occur when you create the virtualenv as sudo and then operate without sudo in the virtualenv.

As found out in your question's comment, the solution here is to create the virtualenv without sudo to be able to work (esp. write) in it without sudo.

permission denied pip virtualenv

I don't think there's anything wrong with your pip installation. virtualenv is itself a Python module, and by default it goes in /usr/local/lib/python2.7/dist-packages, a folder for which your user does not have write permissions. If you have sudo access, it would be easiest to simply try:

sudo pip install virtualenv

Once you've done that, you should be able to create virtualenvs without needing to use sudo. Alternately, there are instructions here for making your own virtual environment, but it looks like you will likely need to do some manual editing of the script it directs you to download.

creating a virtualenv gives a permission denied

Looks like you're trying to create the virtualenv test within /lib/python2.7/site-packages, which, by all rights, you shouldn't have write access to.

Try running cd ~ first, to create the venv in your home directory.

Errno 13 Permission denied when running virtualenv

As suggested in a comment, there was an issue with a custom Distutils config file. This file can apparently be in one of three places (ref):

  • system: <prefix>/lib/pythonver/distutils/distutils.cfg
  • personal: $HOME/.pydistutils.cfg
  • local: setup.cfg

I had meanwhile created a setup.cfg according to this SO answer here with content:

[install]
prefix=

I can no longer remember why I had consulted that answer, or why I had put that file there, but after I removed it, virtualenv worked fine again, and I'm not having any more issues.



Related Topics



Leave a reply



Submit