ycm-core / YouCompleteMe

A code-completion engine for Vim
http://ycm-core.github.io/YouCompleteMe/
GNU General Public License v3.0
25.44k stars 2.81k forks source link

Wrong autocomplete for python (cv2 module) #3418

Closed andrejlevkovitch closed 5 years ago

andrejlevkovitch commented 5 years ago

Issue Prelude

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

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:

I install opencv-4.1.0 with python support (python3.7) and use it in some scripts, but autocomplete is wrong for module cv2 For example:

#!/usr/bin/python3
import numpy as np
import cv2

img = cv2.imread('cat.jpeg', 0)

When I set cv2. then all possible variants it is:

bootstrap       f def bootstrap()                                       
config          m module config                                         
load_config_py2 m module load_config_py2                                
load_config_py3 m module load_config_py3                                
numpy           m module numpy                                          
os              m module os                                             
sys             m module sys                                            
 __doc__         i instance __doc__                                      
 __file__        i instance __file__                                     
 __name__        i instance __name__                                     
__package__     i instance __package__  

Include steps to reproduce here.

Include description of a minimal test case, including any actual code required to reproduce the issue.

I expect that I see all complition variants for cv2 like imshew, waitKey, imwrite and other.

Include description of the expected behaviour.

Unfortunately, for cv2 I see some not valid functions. But for other modules, like numpy, sys or os all works fine.

Include description of the observed behaviour, including actual output, screenshots, etc.

Diagnostic data

VIM - Vi IMproved 8.1 (2018 May 18, compiled Jun  9 2019 11:38:22)
Included patches: 1-1140
Compiled by levkovitch@debian
Huge version without GUI.  Features included (+) or not (-):
+acl               +extra_search      +mouse_netterm     -tag_old_static
+arabic            -farsi             +mouse_sgr         -tag_any_white
+autocmd           +file_in_path      -mouse_sysmouse    -tcl
+autochdir         +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     +textprop
+byte_offset       -hangul_input      +num64             +timers
+channel           +iconv             +packages          +title
+cindent           +insert_expand     +path_extra        -toolbar
+clientserver      +job               +perl              +user_commands
+clipboard         +jumplist          +persistent_undo   +vartabs
+cmdline_compl     +keymap            +postscript        +vertsplit
+cmdline_hist      +lambda            +printer           +virtualedit
+cmdline_info      +langmap           +profile           +visual
+comments          +libcall           -python            +visualextra
+conceal           +linebreak         +python3           +viminfo
+cryptv            +lispindent        +quickfix          +vreplace
+cscope            +listcmds          +reltime           +wildignore
+cursorbind        +localmap          +rightleft         +wildmenu
+cursorshape       +lua               +ruby              +windows
+dialog_con        +menu              +scrollbind        +writebackup
+diff              +mksession         +signs             +X11
+digraphs          +modify_fname      +smartindent       +xfontset
-dnd               +mouse             +startuptime       -xim
-ebcdic            -mouseshape        +statusline        -xpm
+emacs_tags        +mouse_dec         -sun_workshop      +xsmp_interact
+eval              -mouse_gpm         +syntax            +xterm_clipboard
+ex_extra          -mouse_jsbterm     +tag_binary        -xterm_save
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/local/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       
Linking: gcc   -L. -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E   -L/usr/local/lib -Wl,--as-needed -o vim    -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lnsl  -lselinux  -ldl  -L/usr/include/lua5.3/lib -llua -Wl,-E  -fstack-protector-strong -L/usr/local/lib  -L/usr/lib/x86_64-linux-gnu/perl/5.28/CORE -lperl -ldl -lm -lpthread -lcrypt  -L/usr/lib/python3.7/config-3.7m-x86_64-linux-gnu -lpython3.7m -lcrypt -lpthread -ldl -lutil -lm  -lruby-2.5 -lpthread -lgmp -ldl -lcrypt -lm

Output of YcmDebugInfo

Printing YouCompleteMe debug information...
-- Client logfile: /tmp/ycm_qbu41qqz.log
-- Server Python interpreter: /usr/bin/python3
-- Server Python version: 3.7.3
-- Server has Clang support compiled in: True
-- Clang version: clang version 8.0.1-svn357234-1~exp1~20190419131517.7 (branches/release_80)
-- No extra configuration file found
-- Python completer debug information:
--   Python interpreter: /usr/bin/python3
--   Python path: ['/usr/lib/python37.zip', '/usr/lib/python3.7', '/usr/lib/python3.7/lib-dynload', '/usr/local/lib/python3.7/dist-packages', '/usr/lib/python3/dist-packages', '/usr/lib/pyth
on3.7/dist-packages']
--   Python version: 3.7.3
--   Jedi version: 0.13.3
--   Parso version: 0.3.4
-- Server running at: http://127.0.0.1:60957
-- Server process ID: 3188
-- Server logfiles:
--   /tmp/ycmd_60957_stdout_mergtcu6.log
--   /tmp/ycmd_60957_stderr_8vuerq56.log

Contents of YCM, ycmd and completion engine logfiles

OS version, distribution, etc.

Distributor ID: Debian Description: Debian GNU/Linux 10 (buster) Release: 10 Codename: buster

Output of build/install commands

bstaletic commented 5 years ago

I couldn't reproduce this with python 3.7.

Your cursor wasn't in a python file when you executed :YcmDebugInfo, so please post that again.

andrejlevkovitch commented 5 years ago

Your cursor wasn't in a python file when you executed :YcmDebugInfo, so please post that again.

Yes it is my mistake, thank. I already fix that.

I couldn't reproduce this with python 3.7.

Autocomplete for cv2 working on you machine? I also uses python3.7, but it not work for cv2 module (but work with others, like numpy).

bstaletic commented 5 years ago

Autocomplete for cv2 working on you machine? I also uses python3.7, but it not work for cv2 module (but work with others, like numpy).

Yes, for example, cv2.wkex leaves only waitKeyEx as the suggestion.

Here's my debug info, I think there might be something wrong with your python path:


Printing YouCompleteMe debug information...
-- Client logfile: /tmp/ycm_6tno5vtd.log
-- Server Python interpreter: /usr/sbin/python
-- Server Python version: 3.7.3
-- Server has Clang support compiled in: False
-- Clang version: None
-- Extra configuration file found and loaded
-- Extra configuration path: /home/bstaletic/.ycm_extra_conf.py
-- Python completer debug information:
--   Python interpreter: /usr/sbin/python
--   Python path: ['/usr/lib/python37.zip', '/usr/lib/python3.7', '/usr/lib/python3.7/lib-dynload', '/home/bstaletic/.local/lib/python3.7/site-packages', '/usr/lib/python3.7/site-packages']
--   Python version: 3.7.3
--   Jedi version: 0.13.3
--   Parso version: 0.3.4
-- Server running at: http://127.0.0.1:59553
-- Server process ID: 19388
-- Server logfiles:
--   /tmp/ycmd_59553_stdout_0bi7rp8h.log
--   /tmp/ycmd_59553_stderr_fokq8af6.log
andrejlevkovitch commented 5 years ago

I think there might be something wrong with your python path

I think it is not. Paths is right, cv2 module is there. What about .ycm_extra_conf.py? I see you have this, can I look it?

bstaletic commented 5 years ago

Sure, but there's nothing python related in it.

def Settings( **kwargs ):
  return { 'flags': [
    '-std=c++17',
    '-I/home/bstaletic/Temp/test/whereami/src',
    '-Wunused-macros'
    ] }
andrejlevkovitch commented 5 years ago

This is c++ settings, right?

bstaletic commented 5 years ago

Right, like I said, nothing python related.

andrejlevkovitch commented 5 years ago

I found how fix problem: need install opencv-python from pip3. Previous, I uses cv2 module, compiled and installed with opencv.

bstaletic commented 5 years ago

Great. In that case, we can close this.