Domanda

I'm trying to write a sublime text plugin which would make some windows api calls. I did some research and found out that this python library provides the API's that I need to use.

So, I'm trying to to use this library. When I add import statement for it in my sublime text plugin it gives me error

ImportError: No module named win32api

I'd assume that it's because sublime text comes with inbuilt python and I haven't actually installed these libraries on my system it's throwing up these errors. How do I add such libraries in my sublime plugin also How would I distribute such plugin?

È stato utile?

Soluzione

In order to use a third-party library in Sublime, you'll need to include it in your plugin directory, and you'll need to include the correct version for the Python you're working with - 2.6 for ST2, 3.3 for ST3. In order for the next step to succeed properly, install the version of Python you're targeting on your system from python.org. For example, if you're working with ST3, make sure you install Python 3.3.2 on your system.

Then, download the correct version of pywin32 from Christoph Gohlke's Python Extension Packages for Windows repository. Install it on your system, then try copying c:\Python33\Lib\site-packages\win32\ to your Packages/MyPlugin folder in Sublime. The installer makes several directories in site-packages, so depending on the system calls you're planning on making you might need to copy other directories as well - win32com, win32comext, pywin32_system32, and/or pythonwin.

You should now be able to import win32 or import .win32 in your plugin. Good luck!

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top