在Ubuntu 16.04上,使用virtualenv 15.0.1和Python 3.5.2(均使用apt
安装)创建并激活新的Python虚拟环境时:
virtualenv .virtualenvs/wtf -p $(which python3) --no-site-packages
source .virtualenvs/wtf/bin/activate
我得到了以下输出:
Already using interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /home/das-g/.virtualenvs/wtf/bin/python3
Also creating executable in /home/das-g/.virtualenvs/wtf/bin/python
Installing setuptools, pkg_resources, pip, wheel...done.
实际上,pip freeze --all
列出了这4个包:
pip==8.1.2
pkg-resources==0.0.0
setuptools==25.2.0
wheel==0.29.0
尽管如此,我期望pip freeze
(不带--all
)会忽略这些隐式安装的软件包。它确实省略了其中的一些软件包,但并未省略pkg-resources
:
pkg-resources==0.0.0
(pip freeze --local
同样如此)
虽然这与帮助文本一致
$> pip freeze --help | grep '\--all'
--all Do not skip these packages in the output: pip, setuptools, distribute, wheel
在pip freeze
的输出中有pkg-resources
似乎并没有什么用处,甚至可能会有害。(我怀疑这就是为什么从pip-tools运行pip-sync
时会从虚拟环境中卸载pkg-resources,从而微妙地破坏环境。)有没有什么好的理由让pip freeze
列出pkg-resources
而不是省略它呢? 据我记得,在Ubuntu 14.04(带有Python 3.4)上它是不列出来的。