简体   繁体   English

Sublime Text-如何添加任何Python模块的自动完成功能?

[英]Sublime Text- how to add autocompletion of any Python module?

This question is quite general, but I haven't found a straightforward answer yet. 这个问题很笼统,但是我还没有找到一个简单的答案。

Let's assume that I have installed a module to my site-packages folder in Python directory. 假设我已经在Python目录中的site-packages文件夹中安装了一个模块。 Autocompletion in my Sublime Text with Sublime CodeIntel module don't really work. 使用Sublime CodeIntel模块的Sublime Text中的自动补全功能实际上无法正常工作。 It works only with core python packages and even not all of them. 它仅适用于核心python软件包,甚至不能全部使用。

My current, default settings in codeintel config: 我当前在codeintel config中的默认设置:

"codeintel_config": {
    "Python": {
        "env": {
            "PATH": "/usr/local/bin:/usr/local/sbin:$PATH",
            "PYTHONPATH": "/usr/local/lib/python2.7/site-packages:/usr/local/lib/python:$PYTHONPATH"
        }

These paths look quite strange, are they OK ? 这些路径看起来很奇怪,可以吗? (I have default mac settings) (我有默认的mac设置)

I am aware, that there are some other modules (for example Jedi, which requires some configuration), but I'm curious if there is a simple way of adding autocompletion of any Python module to ST ? 我知道,还有其他一些模块(例如Jedi,它需要一些配置),但是我很好奇是否有一种简单的方法可以将任何Python模块的自动完成功能添加到ST吗?

What if a module installs outside of site-packages - for example Kivy ? 如果模块安装在站点软件包之外,例如Kivy,该怎么办?

Those are the commented-out sample paths that the plugin comes with. 这些是插件随附的注释掉的示例路径。 You need to configure it with the an actual pythonpath for your system, which will vary depending on which python you are using (2 vs 3, system vs. python.org vs. homebrew, etc.) 您需要使用系统的实际pythonpath对其进行配置,具体取决于您所使用的python路径(2 vs 3,system vs. python.org vs. homebrew等)。

If you want to get the actual path python is using, you could try: 如果要获取python使用的实际路径,可以尝试:

python -c "import sys;print(':'.join(sys.path[1:]))"

(Or python3 of course.) There might be more in there than you want to actually use though so pick out what you don't want.. (当然也可以是python3 。)虽然可能有很多您不想要实际使用的东西,所以请选择您不想要的东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM