[英]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? 为什么要在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. 更新pip脚本中的shebang以指向虚拟环境的python可执行文件。
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. 在我看来,要么你正在执行一个不属于virtualenv的pip,要么你是,但是被执行的python解释器不是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. 检查你正在执行的pip是否是正确的which pip
,并使用your_envdir/bin/python pip <arguments>
强制来自virtualenv的your_envdir/bin/python pip <arguments>
,而不是仅调用plain pip。
This is strange, because if you correctly activated the environment with bin/activate, you should get the correct pip. 这很奇怪,因为如果你用bin / activate正确激活环境,你应该得到正确的点子。 Are you sure you activated with . bin/activate
你确定你激活了吗. bin/activate
. bin/activate
, and not sh bin/activate
? . bin/activate
,而不是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
. 当我错误地在~/.bashrc
错误地设置PYTHONPATH
时遇到了这个问题。 If echo $PYTHONPATH
returns anything outside your expected environment, delete it with export PYTHONPATH=''
and check your ~/.bashrc
for PYTHONPATH
. 如果echo $PYTHONPATH
返回预期环境之外的任何内容,请使用export PYTHONPATH=''
删除它,并检查~/.bashrc
中的PYTHONPATH
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.