pip freeze includes "pkg-resources==0.0.0"

Bug #1635463 reported by Craig R. Wright
260
This bug affects 54 people
Affects Status Importance Assigned to Milestone
One Hundred Papercuts
Fix Released
Medium
Unassigned
python-pip (Debian)
Fix Released
Unknown
python-pip (Ubuntu)
Fix Released
Medium
Unassigned

Bug Description

First reported against pip at: https://github.com/pypa/pip/issues/4022

According to https://github.com/pypa/pip/issues/4022#issuecomment-254926808:
"this is a bug caused by ubuntu - they should fix it, they lied about metadata"

Pip version:
8.1.2

Python version:
Python 2.7.12

Operating System:
Linux ubuntu 4.4.0-43-generic #63-Ubuntu SMP Wed Oct 12 13:48:03 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

Description:

pip freeze, run from a freshly created virtualenv, always includes

pkg-resources==0.0.0

When not extracted from the output when written to requirements.txt, it causes build failures on deployment when creating virtualenvs from that requirements file.

What I've run:

$ pip freeze
ago==0.0.6
bcrypt==2.0.0
beautifulsoup4==4.3.2
blinker==1.3
cffi==1.5.2
ecdsa==0.11
email==6.0.0a1
Flask==0.10.1
flatland==0.8
funcsigs==1.0.2
gunicorn==19.1.0
itsdangerous==0.24
Jinja2==2.8
MarkupSafe==0.23
mock==2.0.0
newrelic==2.4.0.4
nose2==0.6.5
pbr==1.10.0
pika==0.10.0
pkg-resources==0.0.0
pycparser==2.14
PyMySQL==0.7.9
python-dateutil==2.1
pytz==2014.4
redis==2.10.5
requests==2.11.1
six==1.10.0
SQLAlchemy==1.1.2
textile==2.3.3
Werkzeug==0.11.8

ProblemType: Bug
DistroRelease: Ubuntu 16.04
Package: python-pip 8.1.1-2ubuntu0.2
ProcVersionSignature: Ubuntu 4.4.0-43.63-generic 4.4.21
Uname: Linux 4.4.0-43-generic x86_64
ApportVersion: 2.20.1-0ubuntu2.1
Architecture: amd64
Date: Thu Oct 20 18:24:27 2016
InstallationDate: Installed on 2016-09-27 (23 days ago)
InstallationMedia: Ubuntu-Server 16.04.1 LTS "Xenial Xerus" - Release amd64 (20160719)
PackageArchitecture: all
ProcEnviron:
 TERM=xterm-256color
 PATH=(custom, no user)
 XDG_RUNTIME_DIR=<set>
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: python-pip
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Craig R. Wright (craig-wright) wrote :
Revision history for this message
Craig R. Wright (craig-wright) wrote :
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in python-pip (Ubuntu):
status: New → Confirmed
Changed in python-pip (Ubuntu):
importance: Undecided → Medium
Changed in hundredpapercuts:
status: New → Confirmed
importance: Undecided → Medium
Revision history for this message
Edwin Khoo (edwinksl) wrote :

Question on Ask Ubuntu about this bug: http://askubuntu.com/q/854249/15003.

Revision history for this message
graingert (tagrain) wrote :
graingert (tagrain)
Changed in hundredpapercuts:
status: Confirmed → Invalid
status: Invalid → Confirmed
Revision history for this message
Mark (ms7821) wrote :

Also breaks pipenv https://github.com/pypa/pipenv/issues/1425, and I can't think of a workaround.

Revision history for this message
Mark (ms7821) wrote :
Changed in python-pip (Debian):
status: Unknown → New
Revision history for this message
Brylie Christopher Oxley (brylie) wrote :

This should be higher priority, as it is breaking a significant number of virtualenvs.

Revision history for this message
Riley Shea (rshea001) wrote :

I will add I am continuing to experience this on 19.10 with pip 19.3.

Also, I heard the Pip developers say they were sorry about saying this was Ubuntu's fault for lying about metadata, and that they want to go back to being friends. They did say that if Ubuntu devs were to find a way to fix this they'd be forever grateful.

I hope you two get back together, you made such a good team. <3

Revision history for this message
Louis Bouchard (louis) wrote :

Hello,

for what it's worth, the problem comes from the debianized version of virtualenv which uses a debundled version of pkg_resource which gets added into the virtualenv at creation time :

$ virtualenv .
Running virtualenv with interpreter /usr/bin/python2
New python executable in /home/caribou/git/quividi/test/bin/python2
Also creating executable in /home/caribou/git/quividi/test/bin/python
Installing setuptools, pkg_resources, pip, wheel...done.
$ pip freeze
pkg-resources==0.0.0

Using the pip installed version of virtualenv can be a workable workaround :

$ sudo apt -y purge python3-virtualenv virtualenv tox
$ pip install virtualenv
$ virtualenv .
pip install virtualenv
Collecting virtualenv
  Downloading https://files.pythonhosted.org/packages/c5/97/00dd42a0fc41e9016b23f07ec7f657f636cb672fad9cf72b80f8f65c6a46/virtualenv-16.7.7-py2.py3-none-any.whl (3.4MB)
    100% |████████████████████████████████| 3.4MB 351kB/s
Installing collected packages: virtualenv
Successfully installed virtualenv-16.7.7
$ virtualenv .
New python executable in /home/caribou/git/quividi/test/bin/python
Installing setuptools, pip, wheel...
done.
$ source bin/activate
$ pip freeze
$

hth,
...Louis

Changed in python-pip (Debian):
status: New → Fix Committed
Changed in python-pip (Debian):
status: Fix Committed → Fix Released
Revision history for this message
Scott Kitterman (kitterman) wrote :

Fixed in Focal/Groove.

Changed in python-pip (Ubuntu):
status: Confirmed → Fix Released
Changed in hundredpapercuts:
status: Confirmed → Fix Released
Changed in python-pip (Ubuntu):
assignee: nobody → Tanushree Patil (tanushreepatil)
Revision history for this message
Paul White (paulw2u) wrote :

@Tanushree, this bug has been closed as being fixed. I'm not sure why you would want to now assign it to yourself without a comment.

If you still see an issue then you should open a new report and refer to this bug report in the new bug report's description.

Changed in python-pip (Ubuntu):
assignee: Tanushree Patil (tanushreepatil) → nobody
Revision history for this message
Eugenio La Cava (eugeniolcv) wrote :

This still affect LTS 18.04

Revision history for this message
Steve Z (szekowski) wrote :

This bug is still active using python3-venv and 20.04 (Pop_OS). I am not using virtualenv, just native venv.

Revision history for this message
Malik Rumi (malik-a-rumi) wrote :

I can confirm with @szekowski that this is still a problem. It is why I am here today.

requirements.txt made yesterday, 2021-03-24 on Python 3.8.5 Django 3.1.7 and Ubuntu 20.04.2 LTS inserts pkg-resources==0.0.0.

Furthermore, I would like to point out, if someone just updates their requirements because of one or two new or upgraded packages, they may not realize pkg-resources==0.0.0 is there, and maybe carried over for years and / or various editions of their requirements. You need to point this out to people.

However, taking that line out of my requirements.txt file does not solve my immediate issue, which is persistent rejection of my runtime.txt despite putting every version Heroku claims to support in there. That's why I had high hopes for the "just take pkg.resources out" solution.

Is the supposed ease of this self help solution - the one that did not work for me - contributing to the reason this isn't getting solved?!

Revision history for this message
B AG (bayersglassey-zesty) wrote :

This is an issue for me as well, on Pop_OS.
I created a virtualenv from the python3 I got from `apt install python3`, using `-m venv`.
Inside that virtualenv, `pip freeze` does not show `pkg_resources==0.0.0` until I upgrade pip (in my case, from `pip-20.0.2` to `pip-22.0.4`).

$ uname -a
Linux noo-lappy 5.16.11-76051611-generic #202202230823~1646248261~20.04~2b22243~dev-Ubuntu SMP PREEMPT Th x86_64 x86_64 x86_64 GNU/Linux
$ python3 --version
Python 3.8.10
$ which python3
/usr/bin/python3
$ python3 -m venv test_env
. test$ . test_env/bin/activate
(test_env) $ pip freeze
pip(test_env) $ pip install -U pip
Collecting pip
  Using cached pip-22.0.4-py3-none-any.whl (2.1 MB)
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 20.0.2
    Uninstalling pip-20.0.2:
      Successfully uninstalled pip-20.0.2
Successfully installed pip-22.0.4
(test_env) $ pip freeze
pkg_resources==0.0.0

Revision history for this message
B AG (bayersglassey-zesty) wrote :
Download full text (3.4 KiB)

I notice earlier in this issue, people were mentioning "pkg-resources==0.0.0", whereas I'm seeing "pkg_resources==0.0.0". That's interesting.

Also, this "pkg_resources==0.0.0" seems to show up specifically when installing a *different version* of pip -- not necessarily the *latest* version. Here we see that it doesn't show up when installing new versions of setuptools or wheel, but it does show up when installing an old version of pip:

$ python3 -m venv temp_env && . temp_env/bin/activate
(temp_env) $ pip install -U setuptools
Collecting setuptools
  Using cached setuptools-62.1.0-py3-none-any.whl (1.1 MB)
Installing collected packages: setuptools
  Attempting uninstall: setuptools
    Found existing installation: setuptools 44.0.0
    Uninstalling setuptools-44.0.0:
      Successfully uninstalled setuptools-44.0.0
 Successfully installed setuptools-62.1.0
(temp_env) $ pip freeze
(temp_env) $ pip install -U wheel
Collecting wheel
  Using cached wheel-0.37.1-py2.py3-none-any.whl (35 kB)
Installing collected packages: wheel
Successfully installed wheel-0.37.1
(temp_env) $ pip freeze
(temp_env) $ pip install pip==9.0.3
Collecting pip==9.0.3
  Using cached pip-9.0.3-py2.py3-none-any.whl (1.4 MB)
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 20.0.2
    Uninstalling pip-20.0.2:
      Successfully uninstalled pip-20.0.2
Successfully installed pip-9.0.3
(temp_env) $ pip freeze
pkg-resources==0.0.0
You are using pip version 9.0.3, however version 22.0.4 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

^ Only the very last `pip freeze` outputs "pkg-resources==0.0.0".
Also, uninstalling pkg_resources seems to permanently fix the issue:

$ pip install -U pip
Collecting pip
  Using cached pip-22.0.4-py3-none-any.whl (2.1 MB)
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 20.0.2
    Uninstalling pip-20.0.2:
      Successfully uninstalled pip-20.0.2
pipSuccessfully installed pip-22.0.4
(temp_env) $ pip freeze
pkg_resources==0.0.0
(temp_env) $ pip uninstall pkg_resources
Found existing installation: pkg_resources 0.0.0
Uninstalling pkg_resources-0.0.0:
  Would remove:
    /home/zesty_bag/repos/zestyai/data-ingestion/temp_env/lib/python3.8/site-packages/pkg_resources-0.0.0.dist-info/*
    /home/zesty_bag/repos/zestyai/data-ingestion/temp_env/lib/python3.8/site-packages/pkg_resources/*
Proceed (Y/n)? Y
  Successfully uninstalled pkg_resources-0.0.0
(temp_env) $ pip install pip~=20.0
Collecting pip~=20.0
  Using cached pip-20.3.4-py2.py3-none-any.whl (1.5 MB)
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 22.0.4
    Uninstalling pip-22.0.4:
      Successfully uninstalled pip-22.0.4
Successfully installed pip-20.3.4
(temp_env) $ pip freeze
(temp_env) $ pip install -U pip
Requirement already satisfied: pip in ./temp_env/lib/python3.8/site-packages (20.3.4)
Collecting pip
  Using cached pip-22.0.4-py3-none-any.whl (2.1 MB)
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 20.3.4
    Uninstalling pip-20.3.4:
      ...

Read more...

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.