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
Time needed: 5 minutes.
How to fix: No matching distribution found for pkg-resources==0.0.0
- 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
- Create a clean venv
python3 -m venv venv
- Activate it
- Reinstall requirements
pip install -r requirements.txt
Done! The error should now 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!
I am a developer and entrepreneur from Germany. I chose studying computer science because I love building things. I am of the opinion that there isn’t one truth (especially for computer science concepts) and whoever claims so isn’t that trustworthy in my eyes. I constantly try to improve things and myself. In my spare time I support businesses by offering them most of my services for free. Beside that I am kind of addict to e-learning courses.
Our Book Recommendations on Python (Affiliate)