gpt4 book ai didi

python - SublimeCodeIntel 自动完成在 Pandas 和 Numpy 上失败

转载 作者:太空宇宙 更新时间:2023-11-04 10:32:04 25 4
gpt4 key购买 nike

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

设置:苹果操作系统 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' 情况下没有任何反应。

我无法找到任何文档或之前关于此的问题。我在设置中遗漏了什么吗?我的配置路径中是否缺少某些内容?为什么我的包不能自动完成!?

配置文件和 codintel.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"
]
}
}

codintel.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

最佳答案

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

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

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

关于python - SublimeCodeIntel 自动完成在 Pandas 和 Numpy 上失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25801246/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com