No module named pkg_resources

后端 未结 30 3077
一向
一向 2020-11-22 07:22

I\'m deploying a Django app to a dev server and am hitting this error when I run pip install -r requirements.txt:

Traceback (most recent call la         


        
30条回答
  •  生来不讨喜
    2020-11-22 07:57

    July 2018 Update

    Most people should now use pip install setuptools (possibly with sudo).

    Some may need to (re)install the python-setuptools package via their package manager (apt-get install, yum install, etc.).

    This issue can be highly dependent on your OS and dev environment. See the legacy/other answers below if the above isn't working for you.

    Explanation

    This error message is caused by a missing/broken Python setuptools package. Per Matt M.'s comment and setuptools issue #581, the bootstrap script referred to below is no longer the recommended installation method.

    The bootstrap script instructions will remain below, in case it's still helpful to anyone.

    Legacy Answer

    I encountered the same ImportError today while trying to use pip. Somehow the setuptools package had been deleted in my Python environment.

    To fix the issue, run the setup script for setuptools:

    wget https://bootstrap.pypa.io/ez_setup.py -O - | python
    

    (or if you don't have wget installed (e.g. OS X), try

    curl https://bootstrap.pypa.io/ez_setup.py | python
    

    possibly with sudo prepended.)

    If you have any version of distribute, or any setuptools below 0.6, you will have to uninstall it first.*

    See Installation Instructions for further details.


    * If you already have a working distribute, upgrading it to the "compatibility wrapper" that switches you over to setuptools is easier. But if things are already broken, don't try that.

提交回复
热议问题