Sublime Forum

Help, how do I import packages?

#1

Hello,

I am trying to import multiple packages into sublime. I am trying to import pynput.keyboard, time, os, random, requests, and socket. I am having some trouble with it because I do not know whats already installed and or how to install and import. I really appreciate the help!

Sincerely, TheD3N.

0 Likes

#2

Everything in the standard library for ST’s internal Pyhon versio (3.3) is ready to be imported, i.e. time, os, random, and socket.

requests and pynput.keyboard are third-party packages. The former you can retrieve as a Package Control dependency, but the latter you will have to vendor yourself, i.e. copy into your package folder and hope it supports being imported relatively. Otherwise you’ll need to modify sys.path, which is only a last resort.

0 Likes

#3

I believe what TheD3N is asking is, “Fine, but how is this done?”

I for one can say that “modify sys.path” is probably elementary, but that’s a tall order for someone who wouldn’t know where to begin. What I’m here looking for is a step-by-step manual so that I can learn how you experts do this stuff. Like, where is the sys path, and how do I modify it?

0 Likes

#4

Because it should only be used as a last resort, I did not provide exact steps since the process may be different depending on your usage and you would do best if you understood what this feature is before using it.

Here are a few documentation sites for reference:

https://docs.python.org/3/reference/simple_stmts.html#import
https://docs.python.org/3/library/sys.html#sys.path

Also note that all plugins share the same Python environment.

0 Likes