Sublime Text 2 添加插件模块(MySQLdb) [英] Sublime Text 2 add module for PlugIn (MySQLdb)

查看:46
本文介绍了Sublime Text 2 添加插件模块(MySQLdb)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为 Sublime Text 2 开发一个小插件,但我需要使用 MySQLdb 模块.MySQLdb 模块在我的普通 CLI 中运行良好.但是 SB2 使用自己的 Python 版本.

Im developing a small plugin for Sublime Text 2, but i need to use MySQLdb module. The MySQLdb module works fine from my normal CLI. But SB2 uses its own version of Python.

知道如何安装 MySQKdb 模块以及 在哪里以便 SB2 可以找到它吗?

Any idea how i can install the MySQKdb module and where so SB2 can find it?

Python 安装使用/System/Library/Frameworks/Python.framework/Versions/2.7/

Python installation used /System/Library/Frameworks/Python.framework/Versions/2.7/

谢谢!

推荐答案

我今天正在开发一个插件,我选择的解决方案是将模块放在我的包目录中.换句话说:

I was working on a plug-in today, and the solution I chose was to place the module within my package directory. In otherwords:

Packages
|  MyPackage
|  |  MyPackage.py
|  |  MySQLdb
|  |  | contents of MySQLdb package

您可以根据这些帖子更改 Sublime Text 2 使用的 PYTHONPATH,但如果您不小心,似乎可能存在兼容性问题.

You can change the PYTHONPATH that Sublime Text 2 uses, per these posts, but it seems there may be compatibility issues if you aren't careful.

Sublime Text 2:自定义 PATH 和 PYTHONPATH

Sublime Text2 导入错误:没有名为 Gnuplot 的模块

这让我相信最好的解决方案是创建一个专门用于下载模块的文件夹,仅供 Sublime Text 2 使用,并将其添加到 Sublime Text 的 PYTHONPATH.

This leads me to believe that the best solution would be to create a folder specifically for downloading modules solely for the use of Sublime Text 2, and adding that to Sublime Text's PYTHONPATH.

这篇关于Sublime Text 2 添加插件模块(MySQLdb)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆