eclipsepydevtermcolor

Why Eclipse+PyDev cannot import the module termcolor?


Environments: Ubuntu v12.04 x64 + Eclipse Neon v4.6.0 x64 + PyDev v5.2.0 + Python v2.7.12 + termColor v1.1.0.

In the terminal of Ubuntu, Python command line can import termcolor and output colorful characters using commands like "print colored('hello','red')". It shows termcolor can work properly.

PyCharm community v2016.3 can import the module termcolor and work properly.

However, Eclipse+PyDev give the error "ImportError: No module named termcolor". ("from termcolor import colored" has been written.)

Can any expert give a solution to this problem? Thanks!

Edit: the PYTHONPATH in the interpreter is:

/home/usr/name/eclipseworkspace/pydevTest/src
/home/usr/name/eclipseworkspace/pydevTest/src
/home/usr/name/tools/eclipse-java-neon-R-linux-gtk-x86_64/plugins/org.python.pydev_5.2.0.201608171824/pysrc
/usr/local/lib/python2.7
/usr/local/lib/python2.7/lib-dynload
/usr/local/lib/python2.7/lib-old
/usr/local/lib/python2.7/lib-tk
/usr/local/lib/python2.7/plat-linux2
/usr/local/lib/python2.7/site-packages
/usr/local/lib/python2.7/site-packages/xlrd-1.0.0-py2.7.egg
/usr/local/lib/python2.7/site-packages/xlutils-2.0.0-py2.7.egg
/usr/local/lib/python2.7/site-packages/xlwt-1.1.2-py2.7.egg
/usr/local/lib/python27.zip

and termcolor is:

<module 'termcolor' from '/usr/local/lib/python2.7/dist-packages/termcolor.pyc'

Solution

  • To help in giving you a solution, please add to your module:

    import sys
    print('\n'.join(sorted(sys.path)))
    
    import termcolor
    print(termcolor)
    

    Run it from PyDev and post the output here.

    Then, just run:

    import termcolor
    print(termcolor)
    

    from the console and also say what's the output you have.