简体   繁体   中英

emacs python Elpy auto-complete not working for all

Using 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.
For example,

numpy.

triggers autocompletion, but,

pandas.

does not.

My intuition is that while numpy comes standard with python3, pandas does not. So I need to have emacs to point to the directory where the add-on modules are located. 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. How can I do that?

Numpy自动补全 但是熊猫没有

The problem is almost certainly that elpy isn't using the same Python you think it is.

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

So, your pip show numpy and pip show pandas are using the Python 3.5 pip , because that's the only pip you have.

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 .

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

I believe just configuring elpy-rpc-python-command will cause it to pick up everything else properly. Or you can just do it from within elpy-config itself. But that's probably a better question for emacs.SE than the Python tag on SO.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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