Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
533 views
in Technique[技术] by (71.8m points)

python - Why does pip freeze list "pkg-resources==0.0.0"?

On Ubuntu 16.04 with virtualenv 15.0.1 and Python 3.5.2 (both installed with apt) when I create and activate new Python virtual environment with

virtualenv .virtualenvs/wtf -p $(which python3) --no-site-packages
source .virtualenvs/wtf/bin/activate

I get the following output:

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.

Indeed pip freeze --all lists these 4 packages:

pip==8.1.2
pkg-resources==0.0.0
setuptools==25.2.0
wheel==0.29.0

Though, I'd expect pip freeze (without --all) to omit these implicitly installed packages. It does omit some of them, but not pkg-resources:

pkg-resources==0.0.0

(Same btw. for pip freeze --local)

While this is consistent with the help text

$> pip freeze --help | grep '--all'
  --all                       Do not skip these packages in the output: pip, setuptools, distribute, wheel

having pkg-resources in the pip freeze output doesn't seem very useful and might even be harmful. (I suspect it's why running pip-sync from pip-tools uninstalls pkg-resources from the virtual environment, subtly breaking the environment thereby.) Is there any good reason why pip freeze lists pkg-resources instead of omitting it, too? As far as I remember, it didn't list it on Ubuntu 14.04 (with Python 3.4).

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

According to https://github.com/pypa/pip/issues/4022, this is a bug resulting from Ubuntu providing incorrect metadata to pip. So, no there does not seem to be a good reason for this behaviour. I filed a follow-up bug with Ubuntu. https://bugs.launchpad.net/ubuntu/+source/python-pip/+bug/1635463


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...