virtualenv --no-site-packages 和 pip 仍在寻找全局包? [英] virtualenv --no-site-packages and pip still finding global packages?
问题描述
我的印象是 virtualenv --no-site-packages
会创建一个完全独立和隔离的 Python 环境,但它似乎没有.
I was under the impression that virtualenv --no-site-packages
would create a completely separate and isolated Python environment, but it doesn't seem to.
例如,我在全局安装了 python-django,但希望创建一个具有不同 Django 版本的 virtualenv.
For example, I have python-django installed globally, but wish to create a virtualenv with a different Django version.
$ virtualenv --no-site-packages foo
New python executable in foo/bin/python
Installing setuptools............done.
$ pip -E foo install Django
Requirement already satisfied: Django in /usr/share/pyshared
Installing collected packages: Django
Successfully installed Django
据我所知,上面的 pip -E foo install
应该重新安装新版本的 Django.另外,如果我告诉 pip 冻结环境,我会得到很多包.我希望对于带有 --no-site-packages
的全新环境,这将是空白的?
From what I can tell, the pip -E foo install
above is supposed to re-install a new version of Django. Also, if I tell pip to freeze the environment, I get a whole lot of packages. I would expect that for a fresh environment with --no-site-packages
this would be blank?
$ pip -E foo freeze
4Suite-XML==1.0.2
BeautifulSoup==3.1.0.1
Brlapi==0.5.3
BzrTools==1.17.0
Django==1.1
... and so on ...
我是否误解了 --no-site-packages
应该如何工作?
Am I misunderstanding how --no-site-packages
is supposed to work?
推荐答案
我遇到了这样的问题,直到我意识到(早在我发现 virtualenv 之前),我已经在我的 .bashrc 文件中向 PYTHONPATH 添加目录.因为已经过去一年多了,我并没有立即想到这一点.
I had a problem like this, until I realized that (long before I had discovered virtualenv), I had gone adding directories to the PYTHONPATH in my .bashrc file. As it had been over a year beforehand, I didn't think of that straight away.
这篇关于virtualenv --no-site-packages 和 pip 仍在寻找全局包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!