Youcompleteme: Auto complete not work for python.

Created on 27 Mar 2018  ·  24Comments  ·  Source: ycm-core/YouCompleteMe

Sorry, I'm not sure the meaning of x under Prelude...

I use it means YES! :-)

BUT, fell sad for my problems... :-(

Issue Prelude

Please complete these steps and check these boxes (by putting an x inside
the brackets) _before_ filing your issue:

  • [x] I have read and understood YCM's CONTRIBUTING document.
  • [x] I have read and understood YCM's CODE_OF_CONDUCT document.
  • [x] I have read and understood YCM's README, especially the
    Frequently Asked Questions section.
  • [x] I have searched YCM's issue tracker to find issues similar to the one I'm
    about to report and couldn't find an answer to my problem. (Example Google
    search.
    )
  • [x] If filing a bug report, I have included the output of vim --version.
  • [x] If filing a bug report, I have included the output of :YcmDebugInfo.
  • [x] If filing a bug report, I have attached the contents of the logfiles using
    the :YcmToggleLogs command.
  • [x] If filing a bug report, I have included which OS (including specific OS
    version) I am using.
  • [x] If filing a bug report, I have included a minimal test case that reproduces
    my issue, including what I expected to happen and what actually happened.
  • [ ] If filing a installation failure report, I have included the entire output
    of install.py (or cmake/make/ninja) including its invocation
  • [x] I understand this is an open-source project staffed by volunteers and
    that any help I receive is a selfless, heartfelt _gift_ of their free time. I
    know I am not entitled to anything and will be polite and courteous.
  • [x] I understand my issue may be closed if it becomes obvious I didn't
    actually perform all of these steps.

Thank you for adhering to this process! It ensures your issue is resolved
quickly and that neither your nor our time is needlessly wasted.

Issue Details

Provide a clear description of the problem, including the following key
questions:

  • What did you do?

Download YouCompleteMe by Bundle, then compile and install it.

Include steps to reproduce here.

.vimrc

call vundle#begin()
Plugin 'Valloric/YouCompleteMe ’
call vundle#end()

:PluginInstall

compile && install

mkdir ~/.ycm_build
cd ~/.ycm_build

cmake -G "Unix Makefiles" -DUSE_SYSTEM_BOOST=ON -DUSE_SYSTEM_LIBCLANG=ON . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp  -DUSE_PYTHON2=OFF

cmake --build . --target ycm_core --config Release

config

“ ~/.vimrc
let g:ycm_server_python_interpreter='/usr/bin/python'
let g:ycm_global_ycm_extra_conf='~/.ycm_extra_conf.py'

And something wrong I think is:

 ~/.ycm_build $ cmake -G "Unix Makefiles" -DUSE_SYSTEM_BOOST=ON -DUSE_SYSTEM_LIBCLANG=ON . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp  -DUSE_PYTHON2=OFF

-- The C compiler identification is GNU 7.3.1
-- The CXX compiler identification is GNU 7.3.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PythonLibs: /usr/lib/libpython3.6m.so (found suitable version "3.6.4", minimum required is "3.4") 
-- Using libclang to provide semantic completion for C/C++/ObjC
CMake Warning at /usr/share/cmake-3.10/Modules/FindBoost.cmake:1641 (message):
  No header defined for python3; skipping header check
Call Stack (most recent call first):
  ycm/CMakeLists.txt:205 (find_package)


-- Boost version: 1.66.0
-- Found the following Boost libraries:
--   filesystem
--   regex
--   system
--   python3
-- Using external libclang: /usr/lib/libclang.so.5.0
-- Configuring done
-- Generating done
-- Build files have been written to: /home/roach/.ycm_build

There is a warning for python3, I also try python2 (no warning, also not auto complete...)

CMake Warning at /usr/share/cmake-3.10/Modules/FindBoost.cmake:1641 (message):
  No header defined for python3; skipping header check
Call Stack (most recent call first):
  ycm/CMakeLists.txt:205 (find_package)
  • What did you expect to happen?

auto complete python!!!

  • What actually happened?

YouCompleteMe works well for C/C++, doesn't work for python.

Diagnostic data

Output of vim --version

VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Feb 26 2018 23:02:12)
包含补丁: 1-1542
编译者 Arch Linux
巨型版本 无图形界面。  可使用(+)与不可使用(-)的功能:
+acl               +farsi             +mouse_sgr         -tag_any_white
+arabic            +file_in_path      -mouse_sysmouse    +tcl/dyn
+autocmd           +find_in_path      +mouse_urxvt       +termguicolors
-autoservername    +float             +mouse_xterm       +terminal
-balloon_eval      +folding           +multi_byte        +terminfo
+balloon_eval_term -footer            +multi_lang        +termresponse
-browse            +fork()            -mzscheme          +textobjects
++builtin_terms    +gettext           +netbeans_intg     +timers
+byte_offset       -hangul_input      +num64             +title
+channel           +iconv             +packages          -toolbar
+cindent           +insert_expand     +path_extra        +user_commands
-clientserver      +job               +perl/dyn          +vertsplit
-clipboard         +jumplist          +persistent_undo   +virtualedit
+cmdline_compl     +keymap            +postscript        +visual
+cmdline_hist      +lambda            +printer           +visualextra
+cmdline_info      +langmap           +profile           +viminfo
+comments          +libcall           +python/dyn        +vreplace
+conceal           +linebreak         +python3/dyn       +wildignore
+cryptv            +lispindent        +quickfix          +wildmenu
+cscope            +listcmds          +reltime           +windows
+cursorbind        +localmap          +rightleft         +writebackup
+cursorshape       +lua/dyn           +ruby/dyn          -X11
+dialog_con        +menu              +scrollbind        -xfontset
+diff              +mksession         +signs             -xim
+digraphs          +modify_fname      +smartindent       -xpm
-dnd               +mouse             +startuptime       -xsmp
-ebcdic            -mouseshape        +statusline        -xterm_clipboard
+emacs_tags        +mouse_dec         -sun_workshop      -xterm_save
+eval              +mouse_gpm         +syntax            
+ex_extra          -mouse_jsbterm     +tag_binary        
+extra_search      +mouse_netterm     +tag_old_static    
     系统 vimrc 文件: "/etc/vimrc"
     用户 vimrc 文件: "$HOME/.vimrc"
 第二用户 vimrc 文件: "~/.vim/vimrc"
      用户 exrc 文件: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
         $VIM 预设值: "/usr/share/vim"
编译方式: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -D_FORTIFY_SOURCE=2  -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       
链接方式: gcc   -L. -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.26/core_perl/CORE  -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -L/usr/local/lib -Wl,--as-needed -o vim        -lm -ltinfo -lelf -lnsl    -lacl -lattr -lgpm -ldl   -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.26/core_perl/CORE -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -fstack-protector-strong -L/usr/local/lib  -L/usr/lib/perl5/5.26/core_perl/CORE -lperl -lpthread -lnsl -ldl -lm -lcrypt -lutil -lc   -L/usr/lib -ltclstub8.6 -ldl -lz -lpthread -lieee -lm 

Output of YcmDebugInfo

Printing YouCompleteMe debug information...
-- Client logfile: /tmp/ycm_vy4n9nn9.log
-- Server Python interpreter: /usr/bin/python
-- Server Python version: 3.6.4
-- Server has Clang support compiled in: True
-- Clang version: clang version 5.0.1 (tags/RELEASE_501/final)
-- Extra configuration file found and loaded
-- Extra configuration path: /home/roach/.ycm_extra_conf.py
-- Python completer debug information:
--   JediHTTP running at: http://127.0.0.1:58219
--   JediHTTP process ID: 16204
--   JediHTTP executable: /home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/JediHTTP/jedihttp
--   JediHTTP logfiles:
--     /tmp/jedihttp_58219_stdout_eq6dw_49.log
--     /tmp/jedihttp_58219_stderr_nvrw6z8_.log
--   Python interpreter: /usr/bin/python
-- Server running at: http://127.0.0.1:48033
-- Server process ID: 16152
-- Server logfiles:
--   /tmp/ycmd_48033_stdout_b994wtn8.log
--   /tmp/ycmd_48033_stderr_oo940kq6.log

Contents of YCM, ycmd and completion engine logfiles

YcmToggleLogs

2018-03-28 01:36:18,267 - ERROR - Unable to connect to server
Traceback (most recent call last):
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/packages/urllib3/connection.py", line 137, in _new_conn
    (self.host, self.port), self.timeout, **extra_kw)
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/packages/urllib3/util/connection.py", line 91, in create_connection
    raise err
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/packages/urllib3/util/connection.py", line 81, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] 拒绝连接

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/packages/urllib3/connectionpool.py", line 559, in urlopen
    body=body, headers=headers)
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/packages/urllib3/connectionpool.py", line 353, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python3.6/http/client.py", line 1239, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1285, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1234, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/usr/lib/python3.6/http/client.py", line 964, in send
    self.connect()
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/packages/urllib3/connection.py", line 162, in connect
    conn = self._new_conn()
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/packages/urllib3/connection.py", line 146, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
requests.packages.urllib3.exceptions.NewConnectionError: <requests.packages.urllib3.connection.HTTPConnection object at 0x7fafecbabf98>: Failed to establish a new connection: [Errno 111] 拒绝连接

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/adapters.py", line 376, in send
    timeout=timeout
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/packages/urllib3/connectionpool.py", line 609, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/packages/urllib3/util/retry.py", line 273, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
requests.packages.urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=41551): Max retries exceeded with url: /ready (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x7fafecbabf98>: Failed to establish a new connection: [Errno 111] 拒绝连接',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/roach/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/base_request.py", line 223, in HandleServerException
    yield
  File "/home/roach/.vim/bundle/YouCompleteMe/autoload/../python/ycm/youcompleteme.py", line 248, in CheckIfServerIsReady
    'ready' )
  File "/home/roach/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/base_request.py", line 69, in GetDataFromHandler
    timeout ) )
  File "/home/roach/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/base_request.py", line 189, in JsonFromFuture
    response = future.result()
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/pythonfutures/concurrent/futures/_base.py", line 404, in result
    return self.__get_result()
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/pythonfutures/concurrent/futures/_base.py", line 356, in __get_result
    raise self._exception
  File "/home/roach/.vim/bundle/YouCompleteMe/autoload/../python/ycm/unsafe_thread_pool_executor.py", line 43, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/sessions.py", line 468, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/sessions.py", line 576, in send
    r = adapter.send(request, **kwargs)
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/adapters.py", line 437, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=41551): Max retries exceeded with url: /ready (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x7fafecbabf98>: Failed to establish a new connection: [Errno 111] 拒绝连接',))

OS version, distribution, etc.

Linux xq-pc 4.14.29-1-MANJARO #1 SMP PREEMPT Wed Mar 21 16:48:46 UTC 2018 x86_64 GNU/Linux

Output of build/install commands

I also try to use ./install.py --clang-completer --system-libclang to install.

No errors report. But doesn't work, too.

Most helpful comment

Oh, I get it. You have added py to the g:ycm_filetype_whitelist option but the filetype for Python is python, not py. You need to change that option to:

let g:ycm_filetype_whitelist = {
            \ "c":1,
            \ "cpp":1,
            \ "objc":1,
            \ "sh":1,
            \ "zsh":1,
            \ "zimbu":1,
            \ "python":1,
            \ }

All 24 comments

And the YcmToggleLogs was not the latest, the latest log is empty. Cause I try to use python2 and 3 compile YouCompleteMe so if the ycm_server_python_interprete is not consistant with compile python version it will let me check the YcmToggleLogs.

What did you do?

After having installed successfully, could you include steps to reproduce the issue?

Include a minimal file example and the exact steps you did in Vim and what you expected to see.

Hi, @puremourning

YCM on cpp file:

2018-03-28 09-18-24


YCM on py file:

2018-03-28 09-15-31


open py file by vscode:

2018-03-28 09-21-45


It seems YCM doesn't work with py file. And I don't know why. So, pls help me :-(

That's actually the expected behaviour.
By default you only get the identifier completer, unless you type a semantic trigger.
Typing <C-Space> will force YCM to use semantic completer even without a semantic trigger.

Hi @bstaletic , use C++ if I input a declared variable YCM show the auto-complete. Python file doesn't.

And the auto complete do not work after I type <C-Space>.

2018-03-28 16-27-23

Could tell me what‘s wrong, pls?

You will need to provide the ycmd logs for us to help you.

@bstaletic ths for help.

Here is the YcmToggleLogs.

 [roach@xq-pc YouCompleteMe]$ cat  /tmp/ycmd_37863_stderr_w7lrhcep.log
2018-03-28 16:39:36,655 - INFO - Received ready request
2018-03-28 16:39:58,485 - INFO - Received debug info request
2018-03-28 16:39:58,488 - INFO - Starting JediHTTP server
2018-03-28 16:39:58,489 - INFO - using port 60447
2018-03-28 16:40:43,364 - INFO - Received debug info request
2018-03-28 16:40:43,366 - ERROR - No semantic completer exists for filetypes: ['']
Traceback (most recent call last):
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/../ycmd/handlers.py", line 238, in DebugInfo
    request_data ).DebugInfo( request_data )
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/../ycmd/handlers.py", line 302, in _GetCompleterForRequestData
    return _server_state.GetFiletypeCompleter( request_data[ 'filetypes' ] )
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/../ycmd/server_state.py", line 89, in GetFiletypeCompleter
    current_filetypes ) )
ValueError: No semantic completer exists for filetypes: ['']
[roach@xq-pc YouCompleteMe]$ date
2018年 03月 28日 星期三 16:43:35 CST

That's not the stderr log of a python file. Please open a python file, reproduce your issue and then open the same log.

How about this one, @bstaletic

2018-03-28 16:57:13,866 - ERROR - Unable to connect to server
Traceback (most recent call last):
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/packages/urllib3/connection.py", line 137, in _new_conn
    (self.host, self.port), self.timeout, **extra_kw)
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/packages/urllib3/util/connection.py", line 91, in create_connection
    raise err
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/packages/urllib3/util/connection.py", line 81, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] 拒绝连接

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/packages/urllib3/connectionpool.py", line 559, in urlopen
    body=body, headers=headers)
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/packages/urllib3/connectionpool.py", line 353, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python3.6/http/client.py", line 1239, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1285, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1234, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/usr/lib/python3.6/http/client.py", line 964, in send
    self.connect()
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/packages/urllib3/connection.py", line 162, in connect
    conn = self._new_conn()
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/packages/urllib3/connection.py", line 146, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
requests.packages.urllib3.exceptions.NewConnectionError: <requests.packages.urllib3.connection.HTTPConnection object at 0x7fb87efdbf98>: Failed to establish a new connection: [Errno 111] 拒绝连接

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/adapters.py", line 376, in send
    timeout=timeout
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/packages/urllib3/connectionpool.py", line 609, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/packages/urllib3/util/retry.py", line 273, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
requests.packages.urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=53855): Max retries exceeded with url: /ready (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x7fb87efdbf98>: Failed to establish a new connection: [Errno 111] 拒绝连接',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/roach/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/base_request.py", line 223, in HandleServerException
    yield
  File "/home/roach/.vim/bundle/YouCompleteMe/autoload/../python/ycm/youcompleteme.py", line 248, in CheckIfServerIsReady
    'ready' )
  File "/home/roach/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/base_request.py", line 69, in GetDataFromHandler
    timeout ) )
  File "/home/roach/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/base_request.py", line 189, in JsonFromFuture
    response = future.result()
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/pythonfutures/concurrent/futures/_base.py", line 404, in result
    return self.__get_result()
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/pythonfutures/concurrent/futures/_base.py", line 356, in __get_result
    raise self._exception
  File "/home/roach/.vim/bundle/YouCompleteMe/autoload/../python/ycm/unsafe_thread_pool_executor.py", line 43, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/sessions.py", line 468, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/sessions.py", line 576, in send
    r = adapter.send(request, **kwargs)
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/adapters.py", line 437, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=53855): Max retries exceeded with url: /ready (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x7fb87efdbf98>: Failed to establish a new connection: [Errno 111] 拒绝连接',))

That's the client log which isn't very useful for your issue.

:-(((

But @bstaletic below is all I can find...

[roach@xq-pc tmp]$ cat jedihttp_54297_stderr_an4c9sxs.log
[roach@xq-pc tmp]$ cat jedihttp_54297_stdout_0x5b_m8i.log
[roach@xq-pc tmp]$ cat ycmd_54151_stderr_i4pd9l9u.log
2018-03-28 17:04:51,087 - INFO - Received ready request
2018-03-28 17:06:18,497 - INFO - Received debug info request
2018-03-28 17:06:18,501 - INFO - Starting JediHTTP server
2018-03-28 17:06:18,501 - INFO - using port 54297
[roach@xq-pc tmp]$ cat ycmd_54151_stdout_jy3x9upw.log
serving on http://localhost:54151
[roach@xq-pc tmp]$ cat ycm_3n7__o5i.log
2018-03-28 17:04:50,979 - ERROR - Unable to connect to server
Traceback (most recent call last):
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/packages/urllib3/connection.py", line 137, in _new_conn
    (self.host, self.port), self.timeout, **extra_kw)
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/packages/urllib3/util/connection.py", line 91, in create_connection
    raise err
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/packages/urllib3/util/connection.py", line 81, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] 拒绝连接

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/packages/urllib3/connectionpool.py", line 559, in urlopen
    body=body, headers=headers)
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/packages/urllib3/connectionpool.py", line 353, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python3.6/http/client.py", line 1239, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1285, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1234, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/usr/lib/python3.6/http/client.py", line 964, in send
    self.connect()
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/packages/urllib3/connection.py", line 162, in connect
    conn = self._new_conn()
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/packages/urllib3/connection.py", line 146, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
requests.packages.urllib3.exceptions.NewConnectionError: <requests.packages.urllib3.connection.HTTPConnection object at 0x7fa6332362b0>: Failed to establish a new connection: [Errno 111] 拒绝连接

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/adapters.py", line 376, in send
    timeout=timeout
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/packages/urllib3/connectionpool.py", line 609, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/packages/urllib3/util/retry.py", line 273, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
requests.packages.urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=54151): Max retries exceeded with url: /ready (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x7fa6332362b0>: Failed to establish a new connection: [Errno 111] 拒绝连接',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/roach/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/base_request.py", line 223, in HandleServerException
    yield
  File "/home/roach/.vim/bundle/YouCompleteMe/autoload/../python/ycm/youcompleteme.py", line 248, in CheckIfServerIsReady
    'ready' )
  File "/home/roach/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/base_request.py", line 69, in GetDataFromHandler
    timeout ) )
  File "/home/roach/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/base_request.py", line 189, in JsonFromFuture
    response = future.result()
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/pythonfutures/concurrent/futures/_base.py", line 404, in result
    return self.__get_result()
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/pythonfutures/concurrent/futures/_base.py", line 356, in __get_result
    raise self._exception
  File "/home/roach/.vim/bundle/YouCompleteMe/autoload/../python/ycm/unsafe_thread_pool_executor.py", line 43, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/sessions.py", line 468, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/sessions.py", line 576, in send
    r = adapter.send(request, **kwargs)
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/adapters.py", line 437, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=54151): Max retries exceeded with url: /ready (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x7fa6332362b0>: Failed to establish a new connection: [Errno 111] 拒绝连接',))
[roach@xq-pc tmp]$ 

Wait... your stderr log is empty. But the client can't connect to the server.

Is there anything in :messages?

I create a wycncm.py, nothing shows but Press Enter or other commands to continue.

2018-03-28 17-17-52

Did you set the logging level to debug?

let g:ycm_log_level = 'debug'

Hi, after the debug setting, I got these files, @micbou

[roach@xq-pc tmp]$ ls  -alh | grep ycm
-rw-------  1 roach roach 5.2K 3月  28 19:18 ycm_4uxff8e6.log
-rw-------  1 roach roach  318 3月  28 19:18 ycmd_51051_stderr_61c6kbt_.log
-rw-------  1 roach roach   34 3月  28 19:18 ycmd_51051_stdout_hd6bhy3j.log
-rw-------  1 roach roach    0 3月  28 19:15 ycm_jb6rugml.log
-rw-------  1 roach roach    0 3月  28 19:17 ycm_ovv020fr.log
-rw-------  1 roach roach    0 3月  28 19:17 ycm_r_uh2ya4.log
-rw-------  1 roach roach    0 3月  28 19:17 ycm_weqzz0ec.log

2018-03-28 19:18:21,075 - ERROR - Unable to connect to server
Traceback (most recent call last):
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/packages/urllib3/connection.py", line 137, in _new_conn
    (self.host, self.port), self.timeout, **extra_kw)
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/packages/urllib3/util/connection.py", line 91, in create_connection
    raise err
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/packages/urllib3/util/connection.py", line 81, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] 拒绝连接

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/packages/urllib3/connectionpool.py", line 559, in urlopen
    body=body, headers=headers)
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/packages/urllib3/connectionpool.py", line 353, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python3.6/http/client.py", line 1239, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1285, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1234, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/usr/lib/python3.6/http/client.py", line 964, in send
    self.connect()
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/packages/urllib3/connection.py", line 162, in connect
    conn = self._new_conn()
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/packages/urllib3/connection.py", line 146, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
requests.packages.urllib3.exceptions.NewConnectionError: <requests.packages.urllib3.connection.HTTPConnection object at 0x7f34d283b278>: Failed to establish a new connection: [Errno 111] 拒绝连接

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/adapters.py", line 376, in send
    timeout=timeout
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/packages/urllib3/connectionpool.py", line 609, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/packages/urllib3/util/retry.py", line 273, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
requests.packages.urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=51051): Max retries exceeded with url: /ready (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x7f34d283b278>: Failed to establish a new connection: [Errno 111] 拒绝连接',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/roach/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/base_request.py", line 223, in HandleServerException
    yield
  File "/home/roach/.vim/bundle/YouCompleteMe/autoload/../python/ycm/youcompleteme.py", line 248, in CheckIfServerIsReady
    'ready' )
  File "/home/roach/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/base_request.py", line 69, in GetDataFromHandler
    timeout ) )
  File "/home/roach/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/base_request.py", line 189, in JsonFromFuture
    response = future.result()
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/pythonfutures/concurrent/futures/_base.py", line 404, in result
    return self.__get_result()
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/pythonfutures/concurrent/futures/_base.py", line 356, in __get_result
    raise self._exception
  File "/home/roach/.vim/bundle/YouCompleteMe/autoload/../python/ycm/unsafe_thread_pool_executor.py", line 43, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/sessions.py", line 468, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/sessions.py", line 576, in send
    r = adapter.send(request, **kwargs)
  File "/home/roach/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests/requests/adapters.py", line 437, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=51051): Max retries exceeded with url: /ready (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x7f34d283b278>: Failed to establish a new connection: [Errno 111] 拒绝连接',))

[roach@xq-pc tmp]$ cat ycmd_51051_stderr_61c6kbt_.log
2018-03-28 19:18:21,123 - DEBUG - Global extra conf not loaded or no function YcmCorePreload
2018-03-28 19:18:21,182 - INFO - Received ready request
2018-03-28 19:18:51,920 - INFO - Received debug info request
2018-03-28 19:18:51,924 - INFO - Starting JediHTTP server
2018-03-28 19:18:51,924 - INFO - using port 54461

[roach@xq-pc tmp]$ cat ycmd_51051_stdout_hd6bhy3j.log
serving on http://localhost:51051

[roach@xq-pc tmp]$ ls  -alh | grep jed
-rw-------  1 roach roach    0 3月  28 19:18 jedihttp_54461_stderr_x8qthdge.log
-rw-------  1 roach roach    0 3月  28 19:18 jedihttp_54461_stdout_63mf05sr.log

@micbou

I do set Global extra conf, but why it doesn't loaded?

Maybe your <C-Space> key is already mapped. What's the output of :inoremap <C-Space>?

I do set Global extra conf, but why it doesn't loaded?

Because the extra conf is not used in Python.

This is my .vimrc about YCM:

nnoremap <leader>jc :YcmCompleter GoToDeclaration<CR>
" 只能是 #include 或已打开的文件
nnoremap <leader>jd :YcmCompleter GoToDefinition<CR>


" YCM 补全
let g:ycm_global_ycm_extra_conf='~/.ycm_extra_conf.py'
let g:ycm_server_python_interpreter='/usr/bin/python'
let g:ycm_python_binary_path = '/usr/bin/python'

" YCM 补全菜单配色
" 菜单
" highlight Pmenu ctermfg=2 ctermbg=3 guifg=#005f87 guibg=#EEE8D5
" 选中项
" highlight PmenuSel ctermfg=2 ctermbg=3 guifg=#AFD700 guibg=#106900

" highlight PMenu ctermfg=0 ctermbg=242 guifg=black guibg=darkgrey
" highlight PMenuSel ctermfg=242 ctermbg=8 guifg=darkgrey guibg=black

" 关闭自动弹出的函数原型预览窗口
" set completeopt=menu,menuone
" let g:ycm_add_preview_to_completeopt = 0

" 补全功能在注释中同样有效
let g:ycm_complete_in_comments=1

" 关闭YCM的诊断信息,这样就可以使用其他静态检查插件
let g:ycm_show_diagnostics_ui = 0

" 允许 vim 加载 .ycm_extra_conf.py 文件,不再提示
let g:ycm_confirm_extra_conf=0

" 开启 YCM 标签补全引擎
let g:ycm_collect_identifiers_from_tags_files=1
"" 引入 C++ 标准库 tags
"set tags+=/data/misc/software/app/vim/stdcpp.tags
"set tags+=/data/misc/software/app/vim/sys.tags

" YCM 集成 OmniCppComplete 补全引擎,设置其快捷键
inoremap <leader>; <C-x><C-o>

" 补全内容不以分割子窗口形式出现,只显示补全列表
set completeopt-=preview

" 从第一个键入字符就开始罗列匹配项
let g:ycm_min_num_of_chars_for_completion=1

" 禁止缓存匹配项,每次都重新生成匹配项
let g:ycm_cache_omnifunc=0

" 语法关键字补全
let g:ycm_seed_identifiers_with_syntax=1

let g:syntastic_error_symbol='>>'
let g:syntastic_warning_symbol='>'
let g:syntastic_check_on_open=1
let g:syntastic_check_on_wq=0
let g:syntastic_enable_highlighting=1
let g:syntastic_python_checkers=['pyflakes'] " 使用pyflakes,速度比pylint快
let g:syntastic_javascript_checkers = ['jsl', 'jshint']
let g:syntastic_html_checkers=['tidy', 'jshint']

" 修改高亮的背景色, 适应主题
" highlight SyntasticErrorSign guifg=white guibg=black

" to see error location list
let g:syntastic_always_populate_loc_list = 0
let g:syntastic_auto_loc_list = 0
let g:syntastic_loc_list_height = 5
function! ToggleErrors()
    let old_last_winnr = winnr('$')
    lclose
    if old_last_winnr == winnr('$')
        " Nothing was closed, open syntastic error location panel
        Errors
    endif
endfunction
nnoremap <Leader>s :call ToggleErrors()<cr>
" nnoremap <Leader>sn :lnext<cr>
" nnoremap <Leader>sp :lprevious<cr>

" https://zhuanlan.zhihu.com/p/33046090
" 避免编辑白名单外的文件类型时 YCM也一直分析
let g:ycm_filetype_whitelist = {
            \ "c":1,
            \ "cpp":1,
            \ "objc":1,
            \ "sh":1,
            \ "zsh":1,
            \ "zimbu":1,
            \ "py":1,
            \ }

and the output of :inoremap <C-Space>:

2018-03-29 18-30-45

Looks good. If you type

import os
os.

in a Python file, you don't get any completions?

No, get nothing.

I have to use <leader>;, as I have set inoremap <leader>; <C-x><C-o>.

And if I type

import os
os.

then type <leader>;, it shows me some completions. And in this situation, I can use Tab only to choose useful completions. I mean YCM auto choose a completed completions that I can not type any char to choose the completion I want.

2018-03-29 21-06-04

So wired, seems I'm the only one have this problem...

Oh, I get it. You have added py to the g:ycm_filetype_whitelist option but the filetype for Python is python, not py. You need to change that option to:

let g:ycm_filetype_whitelist = {
            \ "c":1,
            \ "cpp":1,
            \ "objc":1,
            \ "sh":1,
            \ "zsh":1,
            \ "zimbu":1,
            \ "python":1,
            \ }

Yes, It works!

Thank you so much!!!

ths! @micbou

it works for me too! Great!!!! @roachsinai

Greatly, it works for me. Thanks for you to ask this question!

Was this page helpful?
0 / 5 - 0 ratings