YouCompleteMe unavailable: unable to load Python.

Created on 21 Jun 2020  路  9Comments  路  Source: ycm-core/YouCompleteMe

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, using vim -Nu /path/to/YCM/vimrc_ycm_minimal, 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

Despite popularity of this error, and variety of solutions to solve, unfortunately none of the already proposed solutions worked for me.

  • What did you do?
    I installed using arch AUR. I also tried installation using Vundle.

Include steps to reproduce here.
I get this error when I open vim.

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

If you made changes to vimrc_ycm_minimal, pase them here:
I made no change to vimrc_ycm_minimal

 Enable debugging
let g:ycm_keep_logfiles = 1
let g:ycm_log_level = 'debug'

" If the base settings don't repro, paste your existing config for YCM only,
" here:
" let g:ycm_....

" Load YCM (only)
let &rtp .= ',' . expand( '<sfile>:p:h' )
filetype plugin indent on

  • What did you expect to happen?
    No error.

  • What actually happened?
    I get error and autocompletion doesn't work.

Diagnostic data

Output of vim --version

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled May 23 2020 22:02:57)
Included patches: 1-814
Compiled by Arch Linux
Huge version without GUI.  Features included (+) or not (-):
+acl               -farsi             +mouse_sgr         +tag_binary
+arabic            +file_in_path      -mouse_sysmouse    -tag_old_static
+autocmd           +find_in_path      +mouse_urxvt       -tag_any_white
+autochdir         +float             +mouse_xterm       +tcl/dyn
-autoservername    +folding           +multi_byte        +termguicolors
-balloon_eval      -footer            +multi_lang        +terminal
+balloon_eval_term +fork()            -mzscheme          +terminfo
-browse            +gettext           +netbeans_intg     +termresponse
++builtin_terms    -hangul_input      +num64             +textobjects
+byte_offset       +iconv             +packages          +textprop
+channel           +insert_expand     +path_extra        +timers
+cindent           +ipv6              +perl/dyn          +title
-clientserver      +job               +persistent_undo   -toolbar
-clipboard         +jumplist          +popupwin          +user_commands
+cmdline_compl     +keymap            +postscript        +vartabs
+cmdline_hist      +lambda            +printer           +vertsplit
+cmdline_info      +langmap           +profile           +virtualedit
+comments          +libcall           +python/dyn        +visual
+conceal           +linebreak         +python3/dyn       +visualextra
+cryptv            +lispindent        +quickfix          +viminfo
+cscope            +listcmds          +reltime           +vreplace
+cursorbind        +localmap          +rightleft         +wildignore
+cursorshape       +lua/dyn           +ruby/dyn          +wildmenu
+dialog_con        +menu              +scrollbind        +windows
+diff              +mksession         +signs             +writebackup
+digraphs          +modify_fname      +smartindent       -X11
-dnd               +mouse             -sound             -xfontset
-ebcdic            -mouseshape        +spell             -xim
+emacs_tags        +mouse_dec         +startuptime       -xpm
+eval              +mouse_gpm         +statusline        -xsmp
+ex_extra          -mouse_jsbterm     -sun_workshop      -xterm_clipboard
+extra_search      +mouse_netterm     +syntax            -xterm_save
   system vimrc file: "/etc/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/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       
Linking: gcc   -L. -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.30/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    -lacl -lattr -lgpm -ldl   -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.30/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.30/core_perl/CORE -lperl -lpthread -ldl -lm -lcrypt -lutil -lc   -L/usr/lib -ltclstub8.6 -ldl -lz -lpthread -lm 

Output of YcmDebugInfo

E492: Not an editor command: YcmDebugInfo

I think this could cause the issue, I couldn't find ~/.vim/bundle/YouCompleteMe/autoload/youcompleteme.vim in the output :scriptnames. Although I did add set rtp+=~/.vim/bundle/YouCompleteMe to ~/.vimrc, but no help.

Output of YcmDiags

E492: Not an editor command: YcmDebugInfo

Output of git rev-parse HEAD in YouCompleteMe installation directory


Contents of YCM, ycmd and completion engine logfiles

Reproduce the issue with vim -Nu /path/to/YCM/vimrc_ycm_minimal, which
enabled debug logging and other useful diagnostics. Include a link to a
gist containing all of the log files listed by :YcmToggleLogs.

OS version, distribution, etc.

Linux archlinux 5.4.47-1-lts #1 SMP x86_64 GNU/Linux

Output of build/install commands

Include link to a gist containing the invocation and entire output of
install.py if reporting an installation issue.

Most helpful comment

You are absolutely right,
It was my own fault in fact. To add virtualenv support I'd added

"python with virtualenv support
py << EOF
import os
import sys
if 'VIRTUAL_ENV' in os.environ:
  project_base_dir = os.environ['VIRTUAL_ENV']
  activate_this = os.path.join(project_base_dir, 'bin/activate_this.py')
  execfile(activate_this, dict(__file__=activate_this))
EOF

where the py << EOF was causing the error. It got fixed after changing to py3 << EOF
Thanks for the help.

All 9 comments

Hi. Can you do :py3 pass in your vim?

Hi,
py3 pass outputs

E837: This Vim cannot execute :py3 after using :python
E263: Sorry, this command is disabled, the Python library could not be loaded.

the only python I have installed is Python 3.8.3.
which python -> /usr/bin/python
If I ran py print("hello") or pyth0n print("hello") -> it does output hello.

also:
vim --version | grep python

+comments          +libcall           +python/dyn        +visual
+conceal           +linebreak         +python3/dyn       +visualextra

Thanks for the help.

If I ran py print("hello") or pyth0n print("hello") -> it does output hello.

That's loading python2. YCM requires python 3. Vim can only load one version of libpython.so. If another plugin that needs python2 is loaded first, YCM won't be able to work.

As Boris said your vim needs functioning python3.

I recommend finding out which plugin or whatever is using python2 and upgrading it. Otehrwsie there are instructions on the front page for using our legacy python2 branch.

You are absolutely right,
It was my own fault in fact. To add virtualenv support I'd added

"python with virtualenv support
py << EOF
import os
import sys
if 'VIRTUAL_ENV' in os.environ:
  project_base_dir = os.environ['VIRTUAL_ENV']
  activate_this = os.path.join(project_base_dir, 'bin/activate_this.py')
  execfile(activate_this, dict(__file__=activate_this))
EOF

where the py << EOF was causing the error. It got fixed after changing to py3 << EOF
Thanks for the help.

I recently upgraded from fedora 30 to fedora 32 and ran into this issue.

Running :py3 pass made error that vim could not find module libpython37.so. I have python 3 installed, but I needed to install python37. sudo dnf install python37 fixed issue for me. Just commenting in case somebody else has issue. I'm sure there are a lot of culprits for unable to load python.

I recently upgraded MacVim and ran into this issue. MacVim has updated from 3.8 to 3.9, and i only had ~3.9~ 3.8 installed via homebrew. Upgrading python fixed the issue for me.

I recently upgraded MacVim and ran into this issue. MacVim has updated from 3.8 to 3.9, and i only had 3.9 installed via homebrew. Upgrading python fixed the issue for me.

You upgraded python or MacVim?

You upgraded python or MacVim?

Sorry had a confusing typo in my comment.

Upgrading MacVim broke YCM, as it MacVim expected python 3.9 after the upgrade and couldn't start python 3 at all without it present. So, upgrading python fixed the issue.

Was this page helpful?
0 / 5 - 0 ratings