Home Download Buy Blog Forum Support

Python Plugins Not Loading?

Python Plugins Not Loading?

Postby wbond on Mon Jan 09, 2012 5:50 am

I've had a couple of reports that I've not been able to replicate of OS X users having plugins not loading properly. A few people have had trouble with the Alignment plugin, and had to open the Alignment.py file and re-save it to get it to work.

I've also experienced this with the SFTP plugin, however I do not distribute the raw source in order to preserve the ability to license it, so only the .pyc files are included. I'm working on the exact same version of OS X and Sublime and for some reason I currently have two users who see all menu entries, just disabled. I've seen this before if the python contains an error that prevents loading the relevant command classes.

There are no errors in the console, the __init__.py script it being listed as loaded, yet the python command classes appear not to be loading. Completely removing and reinstalling the package has no effect. I even refactored the whole plugin from a single .py file into a directory of around 20 .py files. The .pyc files are all present on both machines, and of the same size.

Anyone have ideas about what could be going on, or ideas to try? I've tried installing all of the other packages the users had to see if it was some sort of conflict, but I was unable to find anything.
wbond
 
Posts: 527
Joined: Mon Feb 28, 2011 5:33 am

Re: Python Plugins Not Loading?

Postby jps on Mon Jan 09, 2012 6:01 am

OS X is the only platform where the system version of Python is used, however some users tweak their system so that doesn't work properly: I've seen people overwrite the default version with the macports version, delete the 64 bit version, or delete the 2.6 version. I doubt it's something as drastic as this going on, but it could be that the systems Python version has been compromised in some way.

If you're seeing this locally, you can add some debug logging into sublime_plugin.py (in the Sublime Text 2 application bundle), in the functions create_xxx_commands, and reload_plugin.
jps
Site Admin
 
Posts: 3062
Joined: Wed Mar 19, 2008 12:33 pm

Re: Python Plugins Not Loading?

Postby wbond on Tue Jan 10, 2012 2:28 am

I have determined that the python imaging library (PIL) is causing the issue. Users who were having trouble were able to fix it by removing PIL from /Library/Python/2.6/site-packages/. I'm currently in the process of installing PIL to see if I can figure out why a package in the python path would cause a whole Sublime plugin to not load, especially without any errors!
wbond
 
Posts: 527
Joined: Mon Feb 28, 2011 5:33 am

Re: Python Plugins Not Loading?

Postby wbond on Tue Jan 10, 2012 6:41 am

It appears that sublime_plugin.py uses __import__() to load *.py files from packages. If a package *.py file has the same name as a file in one of the directories in sys.path, the .py file from the sys.path directory will be reflected. When this happens, no command classes will be found, and your menu items will all appear and be disabled since there are no is_visible() methods. :)

I sent a patch over to Jon related to this.
wbond
 
Posts: 527
Joined: Mon Feb 28, 2011 5:33 am


Return to Technical Support

Who is online

Users browsing this forum: No registered users and 9 guests