问题描述
我安装了emacs-jedi,以获得emacs中python的一些代码完成。一般来说,我必须说,我印象非常深刻!它可以很好的开箱即用,并为内置库快速找到完成。但是,我使用python进行科学目的,并依靠麻木和scipy做我的工作。由于某些原因,我没有完成这些模块。
示例:
import numpy
testVector = numpy.array([1,2,3])
现在键入testVector。等待,没有显示
我不知道为什么它不起作用。它看起来像 sys.path
问题,但它应该没有任何配置工作。但是这里是一个强力修复的一些想法。
(1)运行以下脚本获取numpy的加载路径。
import os
import numpy
print(os.path.dirname(os.path.dirname(numpy .__ file__)))
(2)设置 jedi:server-args
强制添加路径。
(setq jedi:server-args
'(--sys-path THE / PRINTED / PATH / FOR / NUMPY
--sys-pathTHE / PRINTED / PATH / FOR / SCIPY))
另请参见:
编辑1
阅读你对@ syohex的回答的评论,看起来你混淆了一些安装方法。 jeid.el在您拥有jedi.el的目录中使用virtualenvenv /(如果存在)。如果你有virtualenv,el-get会自动创建env /。所以,如果你喜欢系统安装,你需要告诉Jedi.el这样做:忽略evn /:
require'jedi)
(setq jedi:server-command(listpythonjedi:server-script))
另请参见:
编辑2
我不知道为什么发生在你的描述中。以下是几种缩小问题的方法。
-
运行
make tryout
在安装jedi.el的目录(如〜/ .emacs.d / el-get / jedi /
)。
这打开一个干净的(即它不会读取您的设置)Emacs进程与jedi.el的最小设置。我们来看看您是否可以完成numpy和scipy。
-
您可以在Emacs中导入numpy和scipy 吗?你可以在Emacs和shell中有不同的环境变量。运行
M-! python -c'import numpy'RET
。您可以使用env / bin / python导入numpy和scipy。
?最好的办法是从Emacs中检查。
所以首先去安装jedi.el的目录(例如 Cx Cf〜/ .emacs.d / el-get / jedi / RET
)。
然后运行 M- ! env / bin / python -c'import numpy'RET
。如果这不给你一个错误,那么应该可以导入numpy和scipy。
我希望在至少有一个给你一个错误,否则我需要考虑另一种可能性。
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.
这篇关于emacs-jedi没有找到numpy完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!