简体   繁体   中英

Why does pip installs a package outside my virtual environment?

After doing a source of the virtual environment I try

pip install -U --no-deps django-social-auth

and it returns:

OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.6/dist-packages/django_social_auth-0.6.9-py2.6.egg-info/dependency_links.txt'

Why is it trying to write outside the virtualenv?

I ran into this problem when I renamed the directory containing my virtual environment. The hard path pip was using was no longer correct.

Update the shebang in the pip script to point to your virtual environment's python executable.

In my opinion, either you are executing a pip that is not part of the virtualenv, or you are, but the python interpreter that gets executed is not part of the virtualenv. Check if the pip you are executing is the right one with which pip , and force the python from the virtualenv by using your_envdir/bin/python pip <arguments> , instead of just invoking plain pip.

This is strange, because if you correctly activated the environment with bin/activate, you should get the correct pip. Are you sure you activated with . bin/activate . bin/activate , and not sh bin/activate ? They are two different things. Did the prompt change ?

you should probably make sure that you the pip from you virtual environment, so sth. like

./env/bin/pip install -U --no-deps django-social-auth

I ran into this problem when I had mistakingly set PYTHONPATH incorrectly in ~/.bashrc . If echo $PYTHONPATH returns anything outside your expected environment, delete it with export PYTHONPATH='' and check your ~/.bashrc for PYTHONPATH .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM