自动完成与Jedi-vim给出错误

eagi6jfj  于 2023-03-30  发布在  其他
关注(0)|答案(5)|浏览(165)
-- Omni completion (^O^N^P) Pattern not found

这是我在查看Vim中的:消息时遇到的错误。

Please install Jedi if you want to use jedi-vim.
The error was: dlopen(/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyCodecInfo_GetIncrementalDecoder^@  Referenced fro
m: /usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so^@  Expected in: flat namespace^@ in /usr/local/Cellar/python/2.7.12/Frameworks/Python.framework
/Versions/2.7/lib/python2.7/lib-dynload/_io.so

Press ENTER or type command to continue

但是我已经用pip安装了绝地武士

$ pip freeze
jedi==0.9.0
vboxapi==1.0

我尝试从vim运行:python import jedi;,它给出以下错误:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/jedi/__init__.py", line 41, in <module>
    from jedi.api import Script, Interpreter, NotFoundError, set_debug_function
  File "/usr/local/lib/python2.7/site-packages/jedi/api/__init__.py", line 16, in <module>
    from jedi.parser import Parser, load_grammar
  File "/usr/local/lib/python2.7/site-packages/jedi/parser/__init__.py", line 22, in <module>
    from jedi.parser import tokenize
  File "/usr/local/lib/python2.7/site-packages/jedi/parser/tokenize.py", line 16, in <module>
    from io import StringIO
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/io.py", line 51, in <module>
    import _io
ImportError: dlopen(/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyCodecInfo_GetIncrementalDecoder
  Referenced from: /usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
  Expected in: flat namespace
 in /usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so

我的命令行中的Python显示了以下版本

>>> import sys
>>> sys.version
'2.7.12 (default, Jun 29 2016, 14:05:02) \n[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)]'
>>>

但是如果在Vim中运行以下命令

:python import sys; print sys.version

它输出

2.7.10 (default, Oct 23 2015, 19:19:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)]

现在我如何更新vim正在使用的python?/这里到底发生了什么,我该怎么做才能解决它?

gz5pxeao

gz5pxeao1#

这是因为Mac上安装了2个版本的python。一个是默认位于/usr/bin目录下的2.7.10版本。一个是我使用brew安装的,位于/usr/local/bin目录下的2.7.12版本。
Vim使用的是2. 7. 10版本,但是在Brew安装包的文件夹中寻找包。所以我做了Brew卸载Python,一切都很好。
(But我丢失了pip和所有通过pip安装的软件包。我应该更小心的)

ki0zmccv

ki0zmccv2#

我安装了jedi-vim与病原体,它现在的工作。

pip install --user jedi
cd ~/.vim/bundle/
git clone https://github.com/davidhalter/jedi-vim.git

也可以运行this

sudo apt-get install vim-python-jedi

这应该会有帮助

wfveoks0

wfveoks03#

uninstall在我的情况下不是一个解决方案,vim在一开始就抱怨,那就是找不到python支持我做了以下事情:

cd /usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/

mv _io.so _io.so.orig
cp /usr/lib/python2.7/lib-dynload/_io.so ./

(我已经从源代码构建了vim 8-来自github.com/vim/vim.git)

./configure --enable-pythoninterp --with-python-config-dir=/usr/lib/python2.7/config/

make

sudo make install)
7bsow1i6

7bsow1i64#

至少对于Ubuntu 16.04,这是因为默认的Vim包是针对Python 3.5编译的。要修复此错误,除了Jedi的相关包,您需要安装有关Vim的任何内容并安装以下包:

sudo apt-get install vim-addon-manager vim-common vim-gnome-py2 \
vim-gtk3-py2 vim-gui-common vim-nox-py2 vim-python-jedi vim-runtime
aurhwmvo

aurhwmvo5#

如果你使用https://github.com/amix/vimrc,你可以升级它来解决这个问题。

cd ~/.vim_runtime
git reset --hard
git clean -d --force
git pull --rebase
python update_plugins.py

相关问题