emacs-jedi does not find numpy completions

时光怂恿深爱的人放手 提交于 2019-12-03 00:15:35

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.

I can get completion such case. Like following

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

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