Home Download Buy Blog Forum Support

ImportError: No module named sublimeplugin

ImportError: No module named sublimeplugin

Postby isfinite on Sat Jan 29, 2011 10:05 pm

I just installed the Mac OSX Alpha and wanted to get started trying to write a plugin but i'm getting this error in my console whenever I save anything after importing sublimeplugin
"ImportError: No module named sublimeplugin"

Here are the contents of my file I'm doing just to test things out:
Code: Select all
import sublime, sublimeplugin

print "plugin loaded"

class Test1Command(sublimeplugin.TextCommand):
   def run(self, view, args):
      print "command run"



Any ideas on what I may be doing wrong or missing?
isfinite
 
Posts: 5
Joined: Sat Jan 29, 2011 10:02 pm

Re: ImportError: No module named sublimeplugin

Postby guillermooo on Sat Jan 29, 2011 10:11 pm

I Sublime 2, the new name's "sublime_plugin". That should work.
guillermooo
 
Posts: 728
Joined: Thu Jul 23, 2009 9:06 am

Re: ImportError: No module named sublimeplugin

Postby isfinite on Sat Jan 29, 2011 10:22 pm

that works perfectly now, thanks!

one more question, did
Code: Select all
view.runCommand('test1')
change? that's the way the API docs specify to run it but i'm getting an AttributeError.
isfinite
 
Posts: 5
Joined: Sat Jan 29, 2011 10:02 pm

Re: ImportError: No module named sublimeplugin

Postby guillermooo on Sat Jan 29, 2011 10:28 pm

The api docs cover good old Sublime 1.x... Sublime 2 introduces a few changes to how the api works and looks... Most prominently, Sublime 2 api conforms to PEP8, which means camelCase becomes camel_case. However, your best bet is to dir() whatever object you're interested in in the python console (CTRL + ~) and try to find the new names. The old docs are still valid to a great extent, but new ones are badly needed.
guillermooo
 
Posts: 728
Joined: Thu Jul 23, 2009 9:06 am

Re: ImportError: No module named sublimeplugin

Postby isfinite on Sat Jan 29, 2011 10:53 pm

Ah, I see now. Well last question I promise =)

Is there a list around somewhere of good plugins that can be run on Sublime 2 that I could use as an example to look at?

Thanks again for all the help. Much appreciated.
isfinite
 
Posts: 5
Joined: Sat Jan 29, 2011 10:02 pm

Re: ImportError: No module named sublimeplugin

Postby adzenith on Sat Jan 29, 2011 10:58 pm

Sublime Text 2 has only recently been released, and the API is still a little incomplete, so there aren't a lot of plugins for it yet.
If you check out http://sublimetext.info/, you can see a bunch of plugins for ST1, though, and most of the calls are identical in the way that Guillermo summarized.
Feel free to keep asking questions here if you have them, though. :)
adzenith
 
Posts: 1215
Joined: Mon Oct 19, 2009 9:12 pm

Re: ImportError: No module named sublimeplugin

Postby jps on Sat Jan 29, 2011 11:08 pm

For example Sublime Text 2 plugins, you can have a look at the ones that ship with the editor, in the Packages/Default directory (accessible via Preferences/Browse Packages)
jps
Site Admin
 
Posts: 3067
Joined: Wed Mar 19, 2008 12:33 pm

Re: ImportError: No module named sublimeplugin

Postby isfinite on Sun Jan 30, 2011 12:53 am

exactly what i needed. thanks!
isfinite
 
Posts: 5
Joined: Sat Jan 29, 2011 10:02 pm

Re: ImportError: No module named sublimeplugin

Postby ThePythonicCow on Fri Dec 13, 2013 4:17 pm

guillermooo wrote:The old docs are still valid to a great extent, but new ones are badly needed.

Almost three years later now, and the old (Sublime 1) documents are still prominently featured on http://www.sublimetext.com/docs/plugin-examples.

I'm fairly new to Sublime, though I've been programming for decades. I have ended up wasting a couple days worth of my time, trying to figure out why I could not make any extensions work, even these simplest examples.

There is better Sublime 2 plugin documentation at http://net.tutsplus.com/tutorials/pytho ... -2-plugin/

Is there --any-- way that we could get the http://www.sublimetext.com/docs/plugin-examples page to mention http://net.tutsplus.com/tutorials/python-tutorials/how-to-create-a-sublime-text-2-plugin/ or mention this present thread or mention that those examples are applicable only to Sublime 1 or -- something -- to give the poor saps who get lost trying to follow those plugin-examples a bit of a clue?

(I realize that you are almost certainly not the one to ask this question of ... but I don't know who is ... perhaps I'll get lucky and someone will offer a clue as to who might be.)

Here are the two fixes I found were needed in http://www.sublimetext.com/docs/plugin-examples.

  • Wrong sublimeplugin.TextCommand
    Right sublime_plugin.TextCommand
  • Wrong view.runCommand('hello')
    Right view.run_command('hello')
With these two fixes, the HelloCommand runs as 'hello' in both sublime 2 and 3, using the command:
Code: Select all
view.runCommand('hello')

in the console (accessible via Ctrl+~).

Someone must have edit access to that http://www.sublimetext.com/docs/plugin-examples page
ThePythonicCow
 
Posts: 2
Joined: Fri Dec 13, 2013 3:51 pm

Re: ImportError: No module named sublimeplugin

Postby ThePythonicCow on Sun Dec 15, 2013 5:10 pm

The API documentation at http://www.sublimetext.com/docs/api-reference has similar problems - showing the CamelCase of what is, I suppose, Sublime 1, with no clue to the hapless reader that this API is pretty much obsolete now and that the Sublime 2 and 3 API's can be found at http://www.sublimetext.com/docs/2/api_reference.html and http://www.sublimetext.com/docs/3/api_reference.html.

A naive user (well, at least this naive user) might think that http://www.sublimetext.com/docs/api-reference (based both on what the URL and the page state) is the (one and only) API for Sublime.

I would suggest that instead http://www.sublimetext.com/docs/api-reference be renamed to http://www.sublimetext.com/docs/1/api-reference, and that a new page be placed at http://www.sublimetext.com/docs/api-reference, a short page, with essentially just three links, to
Once again, however, I have no clue to whom to properly address these comments.
ThePythonicCow
 
Posts: 2
Joined: Fri Dec 13, 2013 3:51 pm


Return to Plugin Development

Who is online

Users browsing this forum: Yahoo [Bot] and 9 guests