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

2024/11/20 22:21:16

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).

Answer

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

https://en.xdnf.cn/q/26273.html

Related Q&A

How to delete an instantiated object Python?

I am relatively new to object oriented programming and I cannot figure out how to delete an instantiated object in Python. if self.hit_paddle(pos) == True or self.hit_paddle2(pos) == True:bar = bar + 1…

Call method from string

If I have a Python class, and would like to call a function from it depending on a variable, how would I do so? I imagined following could do it:class CallMe: # Classdef App(): # Method one...def Foo(…

Scipy sparse... arrays?

So, Im doing some Kmeans classification using numpy arrays that are quite sparse-- lots and lots of zeroes. I figured that Id use scipys sparse package to reduce the storage overhead, but Im a little …

Using virtualenv with spaces in a path

I set up a virtualenv environment on my Mac, but cannot get Pip to install packages. It fails with the following error:/Volumes/Macintosh: bad interpreter: No such file or directoryI tracked the proble…

What is the difference between a stack and a frame?

Under what situations would I want to use one over the other?What is the difference between:>>> import inspect >>> print(inspect.getouterframes(inspect.currentframe())) [(<frame o…

Python Reverse Find in String

I have a string and an arbitrary index into the string. I want find the first occurrence of a substring before the index.An example: I want to find the index of the 2nd I by using the index and str.rfi…

Is there a direct approach to format numbers in jinja2?

I need to format decimal numbers in jinja2. When I need to format dates, I call the strftime() method in my template, like this:{{ somedate.strftime(%Y-%m-%d) }}I wonder if there is a similar approach …

Why would running scheduled tasks with Celery be preferable over crontab?

Considering Celery is already a part of the stack to run task queues (i.e. it is not being added just for running crons, that seems an overkill IMHO ).How can its "periodic tasks" feature be …

use a css stylesheet on a jinja2 template

I am making a website using html, css, flask and jinja2.I have a page working on a flask server, the buttons and labels etc. are displayed, but the css stylesheet I have is not loaded in.How would I li…

How to extend Python class init

I have created a base class:class Thing():def __init__(self, name):self.name = nameI want to extend the class and add to the init method so the that SubThing has both a name and a time property. How d…