Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
580 views
in Technique[技术] by (71.8m points)

python - Sublime Text2 Import error: No module named Gnuplot

I'm trying to use Gnuplot in a Python script I'm writing in Sublime Text. Whenever I build, I get the error message

Traceback (most recent call last): 
    File "..." line 4, in <module>
       import Gnuplot
ImportError: No module named Gnuplot

If I do the exact same code lines directly in Terminal, I have no problem importing and using Gnuplot.

The import error seems to be common, just with other modules. Usually the fix is related to PYTHONPATH. However, Gnuplot is on my computer located in

/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages

and should thus be found.

Anybody who's got a fix to this one?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Sublime Text 2 comes with its own Python interpreter which sets PYTHONPATH independently from the system Python interpreter you are referring to.

Please see this question how to set a different PYTHONPATH for Sublime. Please note that if the library you are using was compiled against a different Python version than Sublime is using loading the native dynamically linked libraries will probably cause Sublime Text 2 to crash.

https://stackoverflow.com/a/9919953/315168


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
...