Sublime Forum

How to import (use) 3rd party module into a plugin file

#1

I tried to use 3rd part module in plugin, but it didnot work. If i just write an import statement into plugin file, the whole file stops responding to the command. Is it possible to use 3rd part module in any plugin file? If possible, how?

0 Likes

#2

you will need to make sure that the third party module is accessible from and exists as a subfolder in the Packages folder.

which module are you trying to import and what error do you get in the console? (View menu -> Show Console)

0 Likes

#3

Following is the error:
reloading plugin myPlugin.pyplugin
Traceback (most recent call last):
File “D:\Sublime\sublime_plugin.py”, line 76, in reload_plugin
m = imp.reload(m)
File “./imp.py”, line 276, in reload
File “”, line 584, in _check_name_wrapper
File “”, line 1022, in load_module
File “”, line 1003, in load_module
File “”, line 560, in module_for_loader_wrapper
File “”, line 868, in _load_module
File “”, line 313, in _call_with_frames_removed
File “C:\Documents and Settings\hp\Application Data\Sublime Text 3\Packages\myPlugin\pyplugin.py”, line 7, in
import pyparsing as pp
ImportError: No module named 'pyparsing’

But the standard modules can be loaded successfully while they are not in the Packages folder. How dose sublime find them? I think sublime can also finds the 3rd part ones. So do I have to copy the 3rd part module into the Folder? Is there a better method, for example just use the path?

0 Likes

#4

Standard modules are provided by the Python runtime and are found in {Application Folder}/python3.3.zip, next to the corresponding python library.

0 Likes