Home >Backend Development >Python Tutorial >How to Fix the \'No module named pkg_resources\' Error When Using pip?
Users may encounter an error when running pip install -r requirements.txt within a virtual environment, stating "ImportError: No module named pkg_resources." This indicates that the pkg_resources module is missing or inaccessible.
As of July 2018, the recommended solution is to run the following command:
pip install setuptools
This will install or update the setuptools package, which includes the pkg_resources module. If using a package manager, one may also need to install the python-setuptools package.
The pkg_resources module is part of the Python setuptools package. If this package is missing or broken, it can lead to the above error.
Prior to July 2018, a "legacy" method involved using a bootstrap script:
wget https://bootstrap.pypa.io/ez_setup.py -O - | python
However, this method is no longer recommended as the preferred installation mechanism for setuptools .
The above is the detailed content of How to Fix the 'No module named pkg_resources' Error When Using pip?. For more information, please follow other related articles on the PHP Chinese website!