简体   繁体   English

jedi-vim找不到python2 dist-packages,但是python3是的

[英]jedi-vim doesn't find python2 dist-packages, but python3 yes

Jedi-vim does autocompletion for python3 dist-packages, but can't fnd python 2.7 dist-packages. Jedi-vim为python3 dist-packages做了自动完成,但是不能fnd python 2.7 dist-packages。 I run my program using python 2 without problem. 我使用python 2运行我的程序没有问题。 Everything else runs correctly. 其他一切都正常运行。 I found out that vim is running with python3. 我发现vim正在运行python3。

I'm using Ubuntu 16.04 that comes with both python2.7 and python3 installed, but uses python2.7 by default. 我正在使用安装了python2.7和python3的Ubuntu 16.04 ,但默认情况下使用python2.7。 I've installed jedi with pip for python2, and jedi-vim with Bundle. 我已经为python2安装了jedi,为Bundle安装了jedi-vim。

Is there a way to set the path of jedi-vim to look for python2 dist-packages? 有没有办法设置jedi-vim的路径来寻找python2 dist-packages? Do I need to compile vim using python 2 instead? 我是否需要使用python 2编译vim?

I added this line in my .vimrc file trying to change the version: 我在.vimrc文件中添加了这一行,试图更改版本:

let g:jedi#force_py_version = 2

And I got this error message. 我收到此错误消息。

Error: jedi-vim failed to initialize Python: Could not setup g:jedi#force_py_ver
sion: jedi#setup_py_version: Vim(pyfile):E319: Sorry, the command is not availab
le in this version: pyfile /home/santi/.vim/bundle/jedi-vim/initialize.py (in fu
nction jedi#init_python[3]..<SNR>65_init_python, line 6)

Works fine when settings the version to 3 though. 在将版本设置为3时工作正常。

vim --version: vim --version:

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jun 16 2016 10:50:38)
(...)
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -Wdate-time  -g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      
Linking: gcc   -Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim        -lm -ltinfo -lnsl  -lselinux  -lacl -lattr -lgpm -ldl     -L/usr/lib/python3.5/config-3.5m-x86_64-linux-gnu -lpython3.5m -lpthread -ldl -lutil -lm

python (2.7): print sys.path python(2.7):print sys.path

['', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/home/santi/.local/lib/python2.7/site-packages', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/gtk-2.0']

python3 print(sys.path) python3 print(sys.path)

['', '/usr/lib/python35.zip', '/usr/lib/python3.5', '/usr/lib/python3.5/plat-x86_64-linux-gnu', '/usr/lib/python3.5/lib-dynload', '/usr/local/lib/python3.5/dist-packages', '/usr/lib/python3/dist-packages']

.vimrc 的.vimrc

Plugin 'davidhalter/jedi-vim'

Solved! 解决了!

The problem was that I had the vim installed with python3 support and not python2. 问题是我使用python3支持而不是python2安装了vim。 I think is default for Ubuntu 16.04. 我认为是Ubuntu 16.04的默认值。 You can checked with: 您可以查看:

vim --version | grep python

If you output looks like this: 如果输出如下所示:

+cryptv          +linebreak       -python          +vreplace
+cscope          +lispindent      +python3         +wildignore

Then you can run these commands to solve the problem: 然后,您可以运行这些命令来解决问题:

sudo apt install vim-gnome-py2
sudo update-alternatives --set vim /usr/bin/vim.gnome-py2
sudo update-alternatives --set gvim /usr/bin/vim.gnome-py2

Check again for the plus in the python 再次检查python中的加号

+cryptv          +linebreak       +python          +vreplace
+cscope          +lispindent      -python3         +wildignore

That's it. 而已。 Worked for me 为我工作

Thanks to https://github.com/JBakamovic/yavide/blob/master/docs/FAQ.md 感谢https://github.com/JBakamovic/yavide/blob/master/docs/FAQ.md

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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