Sublime Forum

How to import self defined plugin

#1

Under path Packages\myPlugin I biult two modules as plugins for sublime, one (basic.py) defines classes, methods and functions for text processing in general files, while another (pyplugin.py) is aimed at py files。The latter calls the former with import basic (or from basic import *) . but it reports:
import basic
ImportError: No module named ‘basic’

To my surprise, when I cut the commends in basic.py into pyplugin.py and save the modules initially, it seams to work well even it reports the error. But After restarting sublime, the commands in pyplug.py never work again. So, how to import a self defined plugin? How to organize the self-defined plugins.

PS: I inspected codes in modules in Packages\SublimeCodeIntel. I found in SublimeCodeIntel.py, there is a statement “from ordereddict import OrderedDict” in try-block, it also reports the ImportError if one executes the statement. I think the codes in other plugins must call/import each other, and it must be organized properly and work well.

os: winxp
version: 3.3083

0 Likes

#2

Your sublime text version is important here because they behave differently. On st3 you use relative imports for modules in the same package (from . import something) while on st2 you need to use absolute imports, but only fr the top level(!) (import something).

You can usually check the console when a plugin isn’t working to see why, in a trace back.

0 Likes

#3

[quote=“FichteFoll”]Your sublime text version is important here because they behave differently. On st3 you use relative imports for modules in the same package (from . import something) while on st2 you need to use absolute imports, but only fr the top level(!) (import something).

You can usually check the console when a plugin isn’t working to see why, in a trace back.[/quote]

Thank you :smiley:

0 Likes