简体   繁体   English

emacs python Elpy自动完成不适用于所有人

[英]emacs python Elpy auto-complete not working for all

Using Mac OSC 10.13.4, emacs 25.3 (9.0), Python3 使用Mac OSC 10.13.4,emacs 25.3(9.0),Python3

I could have some cases of Elpy autocompletion to work for python3, but for some reason, not always. 我可能有一些Elpy自动补全功能可用于python3,但由于某些原因,并非总是如此。
For example, 例如,

numpy.

triggers autocompletion, but, 触发自动补全,但是

pandas.

does not. 才不是。

My intuition is that while numpy comes standard with python3, pandas does not. 我的直觉是,虽然numpy是python3的标准配置,但pandas没有。 So I need to have emacs to point to the directory where the add-on modules are located. 因此,我需要emacs指向附加模块所在的目录。 In short, emacs does not use the same paths as python3 ... I tried to add a path to the current emacs paths, but it always failed to append these. 简而言之,emacs不使用与python3相同的路径...我试图将路径添加到当前emacs路径,但是它始终无法追加这些路径。 How can I do that? 我怎样才能做到这一点?

Numpy自动补全 但是熊猫没有

The problem is almost certainly that elpy isn't using the same Python you think it is. 问题几乎可以肯定是elpy没有使用您认为的相同的Python。

Since you're on macOS, you have at least one other Python—Apple's pre-installed version of Python 2.7 in /usr/bin/python . 由于您使用的是macOS,因此您至少还有一个其他Python – Apple在/usr/bin/python预安装的Python 2.7版本。 And in most versions of macOS, this includes a special "Extras" directory full of stuff that doesn't normally come builtin with Python—which includes numpy , but not pandas , and in some versions not even pip . 并且在大多数macOS版本中,它包括一个特殊的“ Extras”目录,该目录充满了通常不是Python内置的东西-包括numpy ,但不包括pandas ,在某些版本中甚至不包括pip

So, your pip show numpy and pip show pandas are using the Python 3.5 pip , because that's the only pip you have. 因此,您的pip show numpypip show pandas正在使用Python 3.5 pip ,因为这是您唯一的pip

But if elpy is finding Apple's Python 2.7 rather than the Python 3.5 you installed, it will find the Extras numpy and won't find any pandas . 但是,如果elpy找到的是Apple的Python 2.7,而不是您安装的Python 3.5,它将找到Extras numpy并且不会找到任何pandas

You should also see other weird misbehaviors, like elpy trying to complete print as the Python 2.x statement rather than the Python 3.x function—but the easiest way to diagnose the problem is not to dive into all of those details, and instead just Mx elpy-config . 您还应该看到其他怪异的异常行为,例如elpy尝试以Python 2.x语句而不是Python 3.x函数的形式完成print -但是诊断问题的最简单方法是不深入所有这些细节,而是只是Mx elpy-config It should show something like this: 它应该显示如下内容:

Virtualenv........: None
RPC Python........: 2.7.10 (/usr/bin/python)
Interactive Python: python (/usr/bin/python)
Emacs.............: 25.3.0

… etc. …等等

If so, the answer is that you need to fix the elpy configuration to use /usr/local/bin/python3 (or whatever the appropriate path is to your Python 3.5). 如果是这样,答案是您需要修复elpy配置以使用/usr/local/bin/python3 (或任何适合您的Python 3.5的路径)。

I believe just configuring elpy-rpc-python-command will cause it to pick up everything else properly. 我相信只配置elpy-rpc-python-command会导致它正确地拾取其他所有内容。 Or you can just do it from within elpy-config itself. 或者,您可以只在elpy-config本身中进行操作。 But that's probably a better question for emacs.SE than the Python tag on SO. 但这对于emacs.SE可能是一个比SO上的Python标签更好的问题。

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

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