Home Download Buy Blog Forum Support

ST3 import python library

ST3 import python library

Postby flipmoe on Mon Aug 19, 2013 6:49 am

Hi,

I want to use the jinja2 python library for my new plugin. But I can't get it to work to import it in my main plugin file.

MyPlugin/
jinja2/
MyPlugin.py

Already tried that:
dist_dir = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, dist_dir)

Any ideas how to get that working?

Thank you
Philipp
flipmoe
 
Posts: 3
Joined: Mon Aug 19, 2013 6:45 am

Re: ST3 import python library

Postby sapphirehamster on Mon Aug 19, 2013 8:32 am

It would be really helpful if you posted the actual error message you were getting.

If I had to guess, do you also have the "markupsafe" directory (a dependency of jinja2) in your plugin's directory? Sometimes python's import error messages can be confusing.
sapphirehamster
 
Posts: 91
Joined: Sun Jul 01, 2012 11:19 pm

Re: ST3 import python library

Postby flipmoe on Mon Aug 19, 2013 9:21 am

Thank you for your reply. The error message looks like:

File "../Library/Application Support/Sublime Text 3/Packages/MyPlugin/MyPlugin.py", line 10, in <module>
from jinja2 import Environemnt, FileSystemLoader
File "../Library/Application Support/Sublime Text 3/Packages/MyPlugin/jinja2/__init__.py", line 33, in <module>
from jinja2.environment import Environment, Template
File "../Library/Application Support/Sublime Text 3/Packages/MyPlugin/jinja2/environment.py", line 13, in <module>
from jinja2 import nodes
ImportError: cannot import name nodes

Haven't "markupsafe" in my plugin directory yet...

Thanks
flipmoe
 
Posts: 3
Joined: Mon Aug 19, 2013 6:45 am

Re: ST3 import python library

Postby flipmoe on Mon Aug 19, 2013 6:25 pm

Indeed it was the missing "markupsafe" package...

Thanks!
flipmoe
 
Posts: 3
Joined: Mon Aug 19, 2013 6:45 am


Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 8 guests