3

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!

Roger
  • 7,535
  • 5
  • 41
  • 63

1 Answers1

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.

Community
  • 1
  • 1
Patrick Johnmeyer
  • 31,462
  • 2
  • 26
  • 24
  • Looking at "Package Control", I see that they added to sys.path in their main package .py file so that they could `import semver`. This is useful knowledge. I'll be digging into this more at some point. – Patrick Johnmeyer Feb 05 '13 at 15:37
  • Thanks. At the end I got it working by adjusting my local path, but this is a nice solution. – Roger Feb 06 '13 at 08:51