1

我正在尝试并未能在 Sublime Text 3 中使用 python 自动完成。在多个博客和“设置”指南中建议使用 Sublimecodeintel。当它工作时,它很棒,但我无法让它与我最常用的两个包 numpy 或 pandas 一起工作。

设置:Mac OS X 10.9.4 我已经使用 Homebrew 安装了 python 2.7、numpy 和 pandas。我正在使用 sublime text 3,并使用包管理器安装了 sublimecodeintel。

一个例子:

import pandas as pd
import matplotlib.pyplot as plt

fig = plt.figure() # autocomplete and tooltips works fine.

data = pd.read_csv('file.csv') # no autocomplete or tooltips.

自动完成选项和工具提示是在“。”之后首先在“plt”情况下访问,然后当我开始在括号中写入时再次访问。在“pd”的情况下什么也没有发生。

我还没有找到任何文档或以前的问题。我在设置中错过了什么吗?我的配置路径中缺少什么吗?为什么自动完成不能与我的包一起使用!?

配置文件和 codeintel.log 跟随...

提前谢谢了。

我的 sublimecodeintel 配置文件:

{
    "Python": {
        "python": '/usr/local/bin/python',
        "pythonExtraPaths": [
            "/usr/local/lib/python2.7/site-packages",
            "/usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/",
            "/Library/Python/2.7/site-packages/",
            "/Library/Python/2.7/site-packages",
            "/usr/local/lib/python2.7/site-packages"
        ]
    }
}

codeintel.log 中的输出:

+ Info: processing `Python': please wait...
New env with catalogs for 'Python': PyWin32
Updating indexes for 'Python'... The first time this can take a while.
scan_purelang: path: '/Users/oscarbranson/UCDrive/Projects/APT/MassSpectrum/APT_MS_autorange.py' lang: Python
Python Syntax Error in '/Users/oscarbranson/UCDrive/Projects/APT/MassSpectrum/APT_MS_autorange.py': invalid syntax (<unknown>, line 9)
Doing CodeIntel for 'Python' (hold on)...
eval 'plt' at APT_MS_autorange.py#9  <Trigger 'python-complete-object-members' at 168 (explicit)>
start scope is (<Element 'scope' at 0x1066bdf50>, [])
find 'plt ...' starting at (<Element 'scope' at 0x1066bdf50>, []):
is blob 'matplotlib.pyplot' from <Python curdirlib>? no
is blob 'matplotlib.pyplot' from <Python extradirslib>? yes
imports:: setting reldirlib to: '/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/matplotlib'
is 'plt' accessible on (<Element 'scope' at 0x1066bdf50>, [])? yes: <Element 'scope' at 0x1066aa7d0>
'plt' is <Element 'scope' at 0x1066aa7d0> on (<Element 'scope' at 0x1066aa7d0>, [])
is blob '__future__' from <Python reldirlib>? no
is blob '__future__' from <Python curdirlib>? no
is blob '__future__' from <Python extradirslib>? no
is blob '__future__' from <Python envlib>? no
is blob '__future__' from <Python sitelib>? no
is blob '__future__' from <Python cataloglib: PyWin32>? no
is blob '__future__' from <python-2.7 stdlib>? yes
#... big list here ...

done eval: success
Done 'Python' CodeIntel! Full CodeIntel took 10ms

Autocomplete called (Python) [calltips]
Updating indexes for 'Python'... The first time this can take a while.
scan_purelang: path: '/Users/oscarbranson/UCDrive/Projects/APT/MassSpectrum/APT_MS_autorange.py' lang: Python
Python Syntax Error in '/Users/oscarbranson/UCDrive/Projects/APT/MassSpectrum/APT_MS_autorange.py': invalid syntax (<unknown>, line 11)
Doing CodeIntel for 'Python' (hold on)...
eval 'pd' at APT_MS_autorange.py#27  <Trigger 'python-complete-object-members' at 500 (explicit)>
start scope is (<Element 'scope' at 0x107050de8>, [])
find 'pd ...' starting at (<Element 'scope' at 0x107050de8>, []):
is blob 'pandas' from <Python curdirlib>? no
is blob 'pandas' from <Python extradirslib>? yes
scan_purelang: path: '/usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/compat/__init__.py' lang: Python
# ... big list here ...
done eval: success
Done 'Python' CodeIntel! Full CodeIntel took 411ms
4

1 回答 1

4

我曾经推荐过 SublimeCodeIntel,尽管有这样的随机打嗝,直到我发现Anaconda. 一旦你设置了它(一个非常简短的过程),它就可以工作了。没有要初始化或损坏的数据库,它会自动发现您何时添加了新包,它在后台运行非常不显眼......我不能说太多关于它的好话。它使用 JEDI 自动完成模块等,并且快速准确。它会自动确定类型变量是什么,并使用可以在其上调用的适当方法和类来填充补全。你也可以让它完成参数完成,但这对我来说有点烦人,所以我把它关掉了。它不能做的一件事是方法链接,但没有什么是完美的。它还包括用于代码复杂性检查和 linting 的模块,这很好,但我不需要它,只想在我想 lint 时进行 lint,

我强烈建议尝试一下。除了方法链接之外,我对它非常满意,并且没有回头。您可以做的一件很酷的事情是为"python_interpreter"项目文件中的设置分配不同的值,这样您就可以轻松使用 virtualenvs,或者(像我一样)为 Python 2 编码打开一个项目,为 Python 3 打开另一个项目。

顺便说一句,我不是开发人员,与他/她没有任何关系:)

于 2014-09-12T05:31:24.950 回答