Sublime Forum

First plugin attempt: confused on file/library import/includ

#1

I have a library, written in python, that I’d like to include with one of my plugins.

On my OSX machine, which I believe has python installed, I am able to get my plugin to work!
On my PC, I am not able too; I get errors that seem to indicate packages that don’t exist (os, re, pkg_resources, sys)

My initial reaction is that; I simply don’t have python installed and ST2 doesn’t ship with any python libraries with it’s interpreter aside from sublime and sublime_package.

If I am not able to get a library loaded into ST2, am I allowed to open files for input, reading.

0 Likes

#2

Sublime Text uses OSX’s built-in version of Python.
On Windows (and I think Linux, too), Sublime Text uses a bundled version of Python 2.6.

There should not be an issue with importing os, re, or sys since I’ve used all of these in some of the plugins I’ve made. I’ve never used pkg_resources but I doubt that would cause a problem either.

am I allowed to open files for input, reading.
Yes.

Could you tell me what error you’re getting? What is displayed in the console (control + `)?

0 Likes

#3

Thanks, I was being purposefully vague.

Traceback (most recent call last): File ".\sublime_plugin.py", line 59, in reload_plugin File ".\setup.py", line 3, in <module> from setuptools import setup ImportError: No module named setuptools

I believe this is just me importing wrong, circular or otherwise.

Traceback (most recent call last): File ".\sublime_plugin.py", line 59, in reload_plugin File ".\DocDecorator.py", line 172, in <module> class FigletFont(object): File ".\DocDecorator.py", line 178, in FigletFont reMagicNumber = re.compile(r'^[tf]lf2.') NameError: name 're' is not defined

The code I’m attempting to bundle in a package via: github.com/pwaller/pyfiglet

from pyfiglet import Figlet

Edit: Solved the preceding errors. Narrowed it down to pck_resources not being available (I think) so the file input, file reading will need to be modified.

Edit 2: Pretty sure I have it working now. Here’s some output:

[code]Two
__ _
/ / (_) _____
/ / __/ __ / / / _ / /
(
) /
/ /
/ / / / / ( )
/
/_
/_
// //___/____/

 tall[/code]

Going to finish it up now, thanks for the help.

0 Likes

#4

Hi,
I am really looking forward to this plugin to work: Its the only thing i miss at Sublime2. I love the minimap and having big comments would come just handy to find stuff easily with it.

Currently i have that

Traceback (most recent call last): File ".\sublime_plugin.py", line 59, in reload_plugin File ".\DocDecorator.py", line 3, in <module> from pyfiglet import Figlet File ".\pyfiglet\__init__.py", line 65, in <module> class FigletFont(object): File ".\pyfiglet\__init__.py", line 70, in FigletFont reMagicNumber = re.compile(r'^[tf]lf2.') NameError: name 're' is not defined
Problem.

Is there a quick fix for it available?

0 Likes

#5

I’m actively working on it, I promise.

Once it’s available I’ll be sure to post it.

I am now running into a logic issue… it was working fine at home but now, after converting to file i/o from pkg_resources, it’s smushing and looking terrible on OSX.

This should be ‘What Heck?’:

_ ____ __ __ __ __ ___ | | / / /_ ____ _/ /_ / / / /__ _____/ /_/__ \ | | /| / / __ \/ __ `/ __/ / /_/ / _ \/ ___/ //_// _/ | |/ |/ / / / / /_/ / /_ / __ / __/ /__/ ,< /_/ |__/|__/_/ /_/\__,_/\__/ /_/ /_/\___/\___/_/|_|(_)

Edit: It then became clear; I wasn’t using fixed width font. /idiot

0 Likes