Sublime Text Plugin : Adding python libraries

放肆的年华 提交于 2019-12-30 09:58:34

问题


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?


回答1:


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!



来源:https://stackoverflow.com/questions/19799990/sublime-text-plugin-adding-python-libraries

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!