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
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With