0

How can I troubleshoot this import error? Thanks.

    import scikits.statsmodels.api as sm
  File "C:\Python27\lib\site-packages\scikits\__init__.py", line 1, in <module>
__import__('pkg_resources').declare_namespace(__name__)
ImportError: No module named pkg_resources
bmu
  • 35,119
  • 13
  • 91
  • 108
  • possible duplicate of [What is causing ImportError: No module named pkg_resources after upgrade of Python on os X?](http://stackoverflow.com/questions/1756721/what-is-causing-importerror-no-module-named-pkg-resources-after-upgrade-of-pyth) – eumiro Dec 22 '11 at 10:11
  • @eumiro I have setuptools installed, which seemed to be the issue in post you referenced. –  Dec 22 '11 at 10:18
  • ok, then ignore my comment please. – eumiro Dec 22 '11 at 10:56
  • 2
    Are you sure you have setuptools installed on the python interpreter installed in `C:\Python27`? Have you tried to do a: `import pkg_resources`? – ogrisel Dec 23 '11 at 10:40
  • Okay, I should have tried that first. The import failed. I guess I didn't install setuptools properly. –  Dec 29 '11 at 01:39

1 Answers1

0

I encountered the same ImportError. Somehow the setuptools package had been deleted in my Python environment.

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

curl https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py | python

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.

cwc
  • 8,687
  • 2
  • 20
  • 19
  • I should point out that I edited the answer based on [abarnert](http://stackoverflow.com/users/908494/abarnert)'s [comment](http://stackoverflow.com/questions/7446187/no-module-named-pkg-resources/10538412#comment26822010_10538412). – cwc Aug 22 '13 at 22:49