安装YouCompleteMe后报错。
".vimrc" 95L, 3653C
Error detected while processing function <SNR>35_PollServerReady[7]..<SNR>35_Pyeval:
line 4:
/home/lenovo/.vim/bundle/YouCompleteMe/third_party/requests_deps/requests/requests/__init__.py:83: RequestsDependencyWarning: Old versi
on of cryptography ([1, 2, 3]) may cause slowdown.
解决方法
安装python2.7的pip包管理器,用python2.7升级一下cryptography,就是这里,我习惯性用了pip3,所以浪费了好一会,记住是python2.7的pip。
sudo apt install python-pip
sudo pip install --upgrade cryptography
vim ~/.vimrc
# 在vimrc加入下面这行代码告诉vim,ycm用的是python2.7
let g:ycm_server_python_interpreter = '/usr/bin/python2.7'
退出编辑,执行source命令重新加载一下vimrc,source ~/.vimrc
又报其他error
Error detected while processing function <SNR>27_RestartServer:
line 3:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/lenovo/.vim/bundle/YouCompleteMe/python/ycm/youcompleteme.py", line 291, in RestartServer
self._ShutdownServer()
File "/home/lenovo/.vim/bundle/YouCompleteMe/python/ycm/youcompleteme.py", line 286, in _ShutdownServer
SendShutdownRequest()
File "/home/lenovo/.vim/bundle/YouCompleteMe/python/ycm/client/shutdown_request.py", line 45, in SendShutdownRequest
request.Start()
File "/home/lenovo/.vim/bundle/YouCompleteMe/python/ycm/client/shutdown_request.py", line 39, in Start
display_message = False )
File "/home/lenovo/.vim/bundle/YouCompleteMe/python/ycm/client/base_request.py", line 138, in PostDataToHandler
BaseRequest.PostDataToHandlerAsync( data, handler, timeout ),
File "/home/lenovo/.vim/bundle/YouCompleteMe/python/ycm/client/base_request.py", line 148, in PostDataToHandlerAsync
return BaseRequest._TalkToHandlerAsync( data, handler, 'POST', timeout )
File "/home/lenovo/.vim/bundle/YouCompleteMe/python/ycm/client/base_request.py", line 169, in _TalkToHandlerAsync
return BaseRequest.Session().post(
File "/home/lenovo/.vim/bundle/YouCompleteMe/python/ycm/client/base_request.py", line 217, in Session
from requests_futures.sessions import FuturesSession
File "/home/lenovo/.vim/bundle/YouCompleteMe/third_party/requests-futures/requests_futures/sessions.py", line 24, in <module>
from requests import Session
File "/home/lenovo/.vim/bundle/YouCompleteMe/third_party/requests_deps/requests/requests/__init__.py", line 95, in <module>
from urllib3.contrib import pyopenssl
File "/home/lenovo/.vim/bundle/YouCompleteMe/third_party/requests_deps/urllib3/src/urllib3/contrib/pyopenssl.py", line 46, in <module
>
import OpenSSL.SSL
File "/usr/lib/python2.7/dist-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "/usr/lib/python2.7/dist-packages/OpenSSL/SSL.py", line 118, in <module>
SSL_ST_INIT = _lib.SSL_ST_INIT
AttributeError: 'module' object has no attribute 'SSL_ST_INIT'
又一个模块升级一下
sudo python -m easy_install --upgrade pyOpenSSL
原因分析
安装YouCompleteMe的时候我用的是python3 ./install.py安装的,也就是用的python3,但是ycm的内核使用python2编译的,所以我就得好像也看到有过这样一条报错。
YCM core library compiled for Python 2 but loaded in Python 3
所以里面有很多python2和python3的移植有点问题,解决办法就是指定YCM使用python2.7。