Search code examples
pythonmodulecygwinimporterror

Import Error in Cygwin


When I try to launch python scripts from Cygwin, I get an import error, even though my script clearly imports the necessary modules:

$ python Test_geo.py Traceback (most recent call last): File "Test_geo.py", line 8, in <module> import matplotlib.pyplot as plt ImportError: No module named matplotlib.pyplot

When I run the script in idle, it works. AND, when I run the script in git bash, it works.

I have the relevant Cygwin packages installed: C:\cygwin\lib\python2.7, which includes idlelib, as well as importlib.

Any ideas what the problem might be? Thanks.


Solution

  • In git bash and Cygwin, can you compare the value of your environment variables that are related to python? I would try this in each system:

    env | grep -i python
    

    I suspect you'll find that Cygwin needs some additional paths set in .bashrc.