问题描述
我使用 python virtualenv
工具创建了一个新的虚拟环境.
I created a new virtual environment using the python virtualenv
tool.
virtualenv venv
然后我激活了虚拟环境
source venv/bin/activate
然后我做了一个pip freeze
,这就是我得到的:
Then I did a pip freeze
and this is what I got:
(venv)$ pip freeze
Flask==0.10.1
Werkzeug==0.9.6
itsdangerous==0.24
lxml==3.4.0
numpy==1.9.1
pdir==0.2.2
virtualenv==1.11.6
wsgiref==0.1.2
当我什至没有在虚拟环境中明确安装任何东西时,我想知道怎么安装了这么多库.
I am wondering how so many libraries got installed when I did not even install anything in the virtual environment explicitly.
UPDATE 1:当一些答案建议时,我在第 1 步中也使用了 virtualenv --no-site-packages
来创建一个新的 venv 和同样的问题仍然存在.好像使用这个参数根本没有效果.
UPDATE 1: When some of the answers suggested, I used virtualenv --no-site-packages
as well in Step 1, to create a fresh venv and the same problem persisted. As if using the argument had no effect at all.
更新 2:我能够解决问题并在下面发布了我的经验.正如评论中指出的那样;这是一个相关的问题;链接,帮助我解决了问题.
UPDATE 2: I was able to solve the problem and have posted my experience below. As pointed in the comments; here is a related question; link, that helped me solve the problem.
推荐答案
那些是已经在您的系统上全局安装的库.
Those are the libraries that are already installed globally on your system.
最佳实践是使用 --no-site-packages
创建 virtualenv 时的选项,以避免这个确切的问题.
Best practice is to use the --no-site-packages
option when creating the virtualenv in order to avoid this exact issue.
这篇关于新创建的 Python 虚拟环境中的默认库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!