Wonder what the f**k pkg-resources==0.0.0 is? This is caused by an error of the virtualenv library. Learn how to fix it.

This error is often encountered by Linux users trying to install Python packages from the requirements.txt. This issue occurs only while using a virtual environment, specifically the virtualenv module of Python. When someone used pip freeze > requirements.txt to write the pip freeze's output requirements to a file, a bug of that library leads to this error. It writes the requirement pkg-resources==0.0.0 to the file, this will lead to the described error. There are multiple ways to fix this, depending on whether you are the maintainer of the requirements or merely a user. As the maintainer of the repository, we strongly suggest you switch from virtualenv to venv. Since Python 3.3, the venv module is a built-in module. To change your virtual environment, you may follow the steps below.

How to fix pkg-resources==0.0.0 (5min)

Tools: Python: pip + Python: venv
Supplies: UNIX based OS like MacOS or Linux
No matching distribution found for pkg-resources==0.0.0
  1. Clear the dependencies
    • Write your dependencies and filter out the pkg-resources pip freeze | grep --invert-match pkg-resources > requirements.txt
    • Remove the virtualenv, Assuming it is stored in a folder called "venv" rm -rf venv
    • Make sure you have your virtual enmvironment activated
  2. Create a new virtual environment
    • Create a clean venv python3 -m venv venv
    • Activate it source venv/bin/activate
    • Reinstall requirements pip install -r requirements.txt

Done! The error should no longer occur.

If you are not the maintainer of the repository we suggest you recommend this post to the maintainer. While the maintainer is working on fixing this, you can install the dependencies similarly to the freeze command above, by filtering the packages for it:

cat requirements.txt | grep --invert-match pkg-resources | xargs -n 1 pip install

Explanation

cat will output the content of the requirements, grep will filter it for pkg-resources==0.0.0, and xargs -n 1 will execute pip install for each line returned by the preceding commands.

We hope this solves your issue. If you encounter any problems, please don't hesitate to leave a comment. We will try to help you as soon as possible!

What is pkg-resources?

The pkg_resources module distributed with setuptools provides an API for Python libraries to access their resource files, and for extensible applications and frameworks to automatically discover plugins. It also provides runtime support for using C extensions that are inside zipfile-format eggs, support for merging packages that have separately-distributed modules or subpackages, and APIs for managing Python's current “working set” of active packages.

Python Setuptools, https://setuptools.pypa.io/en/latest/pkg_resources.html

In essence: pkg-resources is a development dependency of packages which use setuptools. Usually it should not be part of any actual packages. This is clearly a bug in virtualenv.