[英]how to isolate virtualenv from local dist-packages?
How do you stop virtualenv using '/usr/local/lib/python2.7/dist-packages'? 你如何使用'/usr/local/lib/python2.7/dist-packages'来阻止virtualenv?
currently it when i run 目前它在我跑的时候
virtualenv --no-site-packages ENV
it still uses the dist-packages that i wish to stop 它仍然使用我希望停止的dist-packages
EDIT: /usr/local/lib/python2.7/dist-packages is in the PYTHONPATH, it needs to be there for other apps 编辑:/usr/local/lib/python2.7/dist-packages在PYTHONPATH中,它需要在那里用于其他应用程序
Your edit explains the behaviour you are observing. 您的编辑说明了您正在观察的行为。
You need to unset PYTHONPATH
when activating the virtualenv. 你需要在激活virtualenv时取消设置
PYTHONPATH
。
unset PYTHONPATH
source /path/to/virtualenv/bin/activate
virtualenv --no-site-packages ENV
creates an empty virtualenv just fine, but your PYTHONPATH
export nullifies your empty virtualenv. virtualenv --no-site-packages ENV
创建一个空的virtualenv就好了,但是你的PYTHONPATH
导出会使你的空virtualenv无效。
In order to make things simpler you can just edit the activate
script and add the unset PYTHONPATH
command there. 为了简化操作,您只需编辑
activate
脚本并在其中添加未unset PYTHONPATH
命令即可。 If you want to restore the original PYTHONPATH upon deactivating the virtualenv you also need to modify the deactivate
function in that file. 如果要在停用virtualenv时恢复原始PYTHONPATH,还需要修改该文件中的
deactivate
功能。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.