Sublime Forum

Importing paramiko (& other libraries)

#1

Hi, I’m new to plugin development. I want to use other python libraries in my plugin, starting with paramiko. I’ve read a few different threads on here about how difficult it is to install third party libraries, but people have reported success. So far I’ve tried 2 things that haven’t worked

  1. Downloading the paramiko source code from github and just putting it in the same folder as my plugin. This seemed to result in a circular dependency (I got an error about paramiko not existing in one of the paramiko files).

What seemed more promising was getting the dependency through package control, although I think I’m missing some understanding about this, because people were saying that you have to do dependencies manually currently but this seems automated?

  1. I created a dependencies.json file (like this example: https://github.com/packagecontrol/requests). But when I ran Satisfy Dependencies, it still didn’t work (for the requests module or paramiko).

I would prefer to find a way where the dependency can be loaded automatically without the user having to do things separately, but mostly I want to be able to use paramiko, so I can load whatever I need to in order to get that to work. My problem is that I don’t understand what these threads are saying to do to load dependencies (or why importing the source code directly didn’t work)

Sources (read them but still confused):
https://packagecontrol.io/docs/dependencies (not sure if packages are the same as plugins in this context)
Dependencies in Package Control 3
Using paramiko library in ST2 plugins

0 Likes

#2

There is a paramiko dependency for Sublime. However, it is only declared to be compatible with Mac OS. The dependency has an open issue for Windows compatibility.

0 Likes

#3

That would be great - I’m on a Mac and desperate at this point! How do I link this to my plugin? Should I just copy those files from github or is there a command to run in Sublime?

0 Likes

#4

Create a file called dependencies.json in the top level of your package with the following contents:

{
    "*": {
        "*": [
            "paramiko"
        ]
    }
}

Then, when someone installs your plugin via Package Control, it will automatically install paramiko as well.

This won’t work on non-Mac OS platforms because of the aforementioned issue with the dependency.

0 Likes

#5

Ah okay, see I already tried doing this (same level as my .py file with the commands I’ve written) but I still get the error (tried restarting Sublime too, but it reloads with the same missing import).

Right now my package is just in the User directory under Packages - could it be something about where that’s located? So the path to dependencies.json is …/Packages/User/dependencies.json

Do I need to manually load it somehow since I’m not installing my own package through package control? How can I get paramiko through package control?

0 Likes

#6

Hi again! So I got it to work with the dependencies.json by putting it in another folder. However, there is now an error from something that paramiko is trying to import – Crypto. I searched around and I tried adding PyCrypto to the dependencies but that’s not being recognized as the same thing. The official paramiko site says to install the cryptography module, which is actually C-based – how can I get this into sublime?

0 Likes

#7

It sounds like there may be an issue with the dependency. I’d open an issue on the sublime-paramiko tracker. It’s possible that the dependency may need an overhaul. It is possible for dependencies to include platform-specific binaries; see the documentation, or sublime-bz2 for an example.

0 Likes

#8

Note that the User package is very special and thus not a normal package. You can use it for quick dabbles, but PC requires a proper package for things like dependency management.

1 Like

#9

I’m sorry to hijack this thread, but I’m facing the problem to import the paraminko on a windows machine. The Plugin Hermes, which I would relly like to use depends on paraminko, especially windows has the dependencie listed.

  • Is there any way to import, update, maintain paraminko to use it on a windows host?
  • Is there any alternative ssh implementation, which can be used in hermes?
0 Likes