DevOps | Cloud | Analytics | Open Source | Programming





How To Fix - "No Module Named Pkg_Resources" Error in Django\Python ?



In this post, we will explore How To Fix - "No Module Named Pkg_Resources" Error in Django\Python. Error Log -


No Module Named Pkg\_Resources


ImportError: No module named pkg\_resources

  Generally this error message is triggered by some missing or broken Python setuptools package. First thing first, few basic sanity checks to be done -

  • What OS you are using ?
  • What Python version you are using ?
  • Is your IPython or Python is correctly setup in your PYTHONPATH ?
  • Are you using setuptools ? Be aware that python would need specific setup tools with respect to OS and version used.
  • Is your setuptools package broken ?
  • There might be Compatibility issue Between Python Version, PyInstaller Version & SetupTools Version.
  Once done with basic checks, lets proceed with the next steps.  

Version Specific:

  • Install specific setuptools.

pip install setuptools==45.0.0

 

Generic :

If you want to upgrade your setuptools to some specific version, use below -


pip install --upgrade 'setuptools<45.0.0'

  If you have already installed setuptools, use below -


sudo pip install setuptools --upgrade
pip install --upgrade distribute

OR


sudo easy\_install install setuptools --upgrade

  If you don't have setuptools, install it using below -


pip install setuptools

OR Install SetUpTools of specific version.


pip install setuptools==45.0.0

  Few other options of installing setuptools


sudo apt install --reinstall python3-pkg-resources python3-setuptools


sudo apt-get install --reinstall python-pkg-resources

 

Miscellaneous :

  • Add the following to the code.

import pkg\_resources.py2\_warn

  • Alternatively use below

pyinstaller --hidden-import=pkg\_resources.py2\_warn --onefile myprog.py

  Hope this helps to fix the issue.  

Other Reads -

 


No Module Named Pkg\_Resources ,ImportError: No module named pkg\_resources ,importerror: no module named pkg\_resources centos 7 ,importerror: no module named pkg\_resources redhat ,modulenotfounderror no module named 'pkg\_resources' ubuntu ,no module named 'pkg\_resources.py2\_warn' ,no module named pip ,no module named pkg\_resources ansible ,no module named pkg\_resources arch ,no module named pkg\_resources centos 7 ,no module named pkg\_resources centos 7 ,no module named pkg\_resources debian ,no module named pkg\_resources debian ,no module named pkg\_resources debian ,no module named pkg\_resources gentoo ,no module named pkg\_resources mac ,no module named pkg\_resources mac ,no module named pkg\_resources mac ,no module named pkg\_resources python ,no module named pkg\_resources ubuntu ,no module named pkg\_resources windows ,python ,yocto modulenotfounderror: no module named 'pkg\_resources' ,