virtualenv --no-site-packages和pip仍在查找全局软件包吗? [英] virtualenv --no-site-packages and pip still finding global packages?

查看:107
本文介绍了virtualenv --no-site-packages和pip仍在查找全局软件包吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我给人的印象是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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆