问题
Im developing a small plugin for Sublime Text 2, but i need to use MySQLdb module. The MySQLdb module works fine from my normal CLI. But SB2 uses its own version of Python.
Any idea how i can install the MySQKdb module and where so SB2 can find it?
Python installation used /System/Library/Frameworks/Python.framework/Versions/2.7/
Thanks!
回答1:
I was working on a plug-in today, and the solution I chose was to place the module within my package directory. In otherwords:
Packages
| MyPackage
| | MyPackage.py
| | MySQLdb
| | | contents of MySQLdb package
You can change the PYTHONPATH that Sublime Text 2 uses, per these posts, but it seems there may be compatibility issues if you aren't careful.
Sublime Text 2: custom PATH and PYTHONPATH
Sublime Text2 Import error: No module named Gnuplot
This leads me to believe that the best solution would be to create a folder specifically for downloading modules solely for the use of Sublime Text 2, and adding that to Sublime Text's PYTHONPATH.
来源:https://stackoverflow.com/questions/12863503/sublime-text-2-add-module-for-plugin-mysqldb