emacs-jedi does not find numpy completions

点点圈 提交于 2019-12-20 10:44:49

问题


I installed emacs-jedi to get some code completion for python in emacs. In general, I must say that I am very impressed! It works well out of the box and finds completions quickly for built -in libraries. However, I use python for scientific purposes and rely on numpy and scipy for my work. For some reason, I get no completions for these modules.

Example:

import numpy 

testVector = numpy.array([1,2,3])

now typing testVector. and waiting, nothing shows up


回答1:


I wonder why it does not work. It looks like sys.path problem but it should work without any configuration. But here is some idea for a brute force fix.

(1) Run the following script to get load path for numpy.

import os
import numpy
print(os.path.dirname(os.path.dirname(numpy.__file__)))

(2) Set jedi:server-args like this to forcefully add the path.

(setq jedi:server-args
      '("--sys-path" "THE/PRINTED/PATH/FOR/NUMPY"
        "--sys-path" "THE/PRINTED/PATH/FOR/SCIPY"))

See also: http://tkf.github.com/emacs-jedi/#jedi:server-args


Edit 1

Reading your comment on @syohex's answer, it looks like you mixed up some installation methods. jeid.el uses the virtualenv "env/" in the directory in which you have jedi.el, if it exists. el-get automatically creates "env/" if you have virtualenv. So, if you like system installation, you need to tell Jedi.el to ignore "evn/" by doing this:

(require 'jedi)
(setq jedi:server-command (list "python" jedi:server-script))

See also: http://tkf.github.com/emacs-jedi/#jedi:server-command


Edit 2

I have no clue why is that happening from your description. Here are several ways to narrow down the problem.

  1. Run make tryout in the directory in which jedi.el is installed (like ~/.emacs.d/el-get/jedi/).

    This opens a clean (i.e., it does not read your setup) Emacs process with minimal setup for jedi.el. Let's see if you can complete numpy and scipy.

  2. Can you import numpy and scipy in Emacs? You could have different environment variable in Emacs and shell. Run M-! python -c 'import numpy' RET. If this does not give you an error, then it is fine.

  3. Can you import numpy and scipy using env/bin/python? The best way to do it is to check it from Emacs.

    So first go to the directory in which jedi.el is installed (e.g., C-x C-f ~/.emacs.d/el-get/jedi/ RET).

    Then run M-! env/bin/python -c 'import numpy' RET. If this does not give you an error, then it should be possible to import numpy and scipy.

I hope at least one of them gives you an error, otherwise I need to think about another possibility.




回答2:


I can get completion such case. Like following

You may use old requirement modules(jedi, epc, argparse). You should update them and try again.



来源:https://stackoverflow.com/questions/14708453/emacs-jedi-does-not-find-numpy-completions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!