5

I've just installed pylint via the Cygwin package installer, and can run it from the bash command line on any .py file. But if I try to programatically import it inside a Python session, it fails:

>>> import pylint
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named pylint

However, if I do the following steps (which I found inside the pylint command line utility file), it works:

>>> __requires__ = 'pylint==1.3.1'
>>> from pkg_resources import load_entry_point
>>> import pylint
>>> pylint.__file__
'/usr/lib/python2.7/site-packages/pylint-1.3.1-py2.7.egg/pylint/__init__.pyc'

I don't have to do the extra steps on the few linux systems I tested. Why do I have to perform extra steps in Cygwin?

For informational purposes, here is my sys.path:

$ python -c "import sys; print '\n'.join(sys.path)"
/usr/lib/python2.7/site-packages/logilab_common-0.62.0-py2.7.egg
/home/lance/sdp/prereqs/python/lib/python
/usr/lib/python27.zip
/usr/lib/python2.7
/usr/lib/python2.7/plat-cygwin
/usr/lib/python2.7/lib-tk
/usr/lib/python2.7/lib-old
/usr/lib/python2.7/lib-dynload
/usr/lib/python2.7/site-packages
/usr/lib/python2.7/site-packages
textral
  • 1,029
  • 8
  • 13
  • It would be useful to [edit] your question to include the Python path: `python -c "import sys; print '\n'.join(sys.path)"` – Anthony Geoghegan Aug 23 '16 at 10:43
  • @AnthonyGeoghegan Good idea, see edits... – textral Aug 24 '16 at 00:30
  • 1
    Your Python path looks fine - aside from the repeated `site-packages` but that shouldn't cause the problem. I just installed the `pylint` package for Python 2.7 using the Cygwin installer on my machine and it worked just as it should. The only thing I can suggest is to use the Cygwin installer to reinstall the `python-setuptools` (and other Python packages). – Anthony Geoghegan Aug 26 '16 at 08:55

0 Answers0