简体   繁体   English

为什么pip会在我的虚拟环境之外安装一个包?

[英]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.

相关问题 python 虚拟环境是否避免冗余安装? - Does a python virtual environment avoid redundant installs? pip两次安装软件包 - pip installs package twice Python package 全局安装,但在虚拟环境中失败 - Python package installs globally but fails within virtual environment 我在虚拟环境外安装了一个 package 但不能在虚拟环境中使用 - I installed a package outside virtual environment but cannot use it in the virtual environment 在虚拟环境中创建.pth文件,以使我的程序包可导入而无需使用pip或import-utils - Create .pth file in virtual environment to make my package importable without using pip or import-utils pip 在哪里安装带有虚拟环境的包? - Where does pip install packages with a virtual environment? 为什么 pip 只从缓存安装包? - why does the pip installs the packages only from the cache? 为什么“pip install”不包含我的package_data文件? - Why does “pip install” not include my package_data files? 为什么在虚拟环境中使用 subprocess.run() 执行“python -m pip”时会运行错误的 pip? - Why does 'python -m pip' runs the wrong pip when executed using subprocess.run() from a virtual environment? 为什么我的程序在本地运行,而不是在虚拟环境中运行? - Why does my program run locally, but not in the virtual environment?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM