Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

managing python import dependencies in SublimeText2 plugin. specifically unicodedata lib

I'm trying to fix a little SublimeText2 plugin. the problem seems to be (from SublimeText python console) to be an import error:

Traceback (most recent call last):
  File ".\sublime_plugin.py", line 62, in reload_plugin
  File ".\rtl.py", line 4, in <module>
    from algorithm import get_display
  File "lang\algorithm.py", line 20, in <module>
    from unicodedata import bidirectional, mirrored
ImportError: No module named unicodedata

since unicodedata is the standard python library, I tried to import it directly in the console and got the same import error. I figured this is because sublimetext isn't using the system installed python version (I'm using python2.7 in a windows machine) but It's own bundled 2.6 python which doesn't bundle the whole standard library.

when I try the import from my usual python interpreter everything works fine.

I tried adding a .pth file that points to "c:\python27\lib" and site-packages etc. which didn't help. adding directly to the path like this:

sys.path.append(c:\\Python27\\lib)

didn't help either. also tried to tweaked my user setting file to include:

{
    "PATH": "C:\\Python27;c:\\Python27\\Scripts",
    "PYTHONPATH": "C:\\Python27\\Lib;C:\\Python27\\Lib\\site-packages;C:\\Python27\\DLLs"
}

my question divides into two:

  1. how to solve this problem specifically on my dev computer
  2. what is the right way to solve this universally for people trying to install the plugin. making the plugin dynamically aware of the default python installation and adding it to the path.

Also, the strangest thing: The main SublimeText folder in program files actually has the unicodedata.pyd file in it. so I can't figure what the problem is!

like image 235
alonisser Avatar asked Oct 19 '12 12:10

alonisser


1 Answers

Looks like this might be a ST2 bug rather than something you're doing wrong: http://www.sublimetext.com/forum/viewtopic.php?f=3&t=3462

like image 96
jcartledge Avatar answered Oct 30 '22 10:10

jcartledge