Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ycm_core loading issues on Ubuntu 16.04 #2136

Closed
Valloric opened this issue Apr 23, 2016 · 26 comments

Comments

@Valloric
Copy link
Member

commented Apr 23, 2016

Ugh, I thought we were done with this, but no.

So I moved my home workstation to Ubuntu 16.04 and lo and behold, we don't work there out-of-the-box. install.py gives ImportError: dynamic module does not define init function (PyInit_ycm_core)

Of course, I know how to fix this. The most trivial is to run python3 install.py <args> instead of just ./install.py <args>. We also have an entry in the FAQ with another workaround.

But it really must work out-of-the-box on the most frequently used Linux distro. We don't have much choice here; either it does and all is well in the world, or it doesn't and we'll get inundated with issue reports, no matter how well we document the issue.

The root of the problem is that despite reports that 16.04 will have system python default to python 3, that's wrong.

$ python --version
Python 2.7.11+
$ /usr/bin/env python --version
Python 2.7.11+

So it's still 2.7 as the default. BUT, the default vim is compiled against python 3! vim --version has -python and +python3.

The result is that running ./install.py makes it run inside a python 2 interpreter, which means that in that install file:

use_python2 = 'ON' if PY_MAJOR == 2 else 'OFF'
cmake_args.append( '-DUSE_PYTHON2=' + use_python2 )

so we end up compiling the libs against python 2. But then YCM uses sys.executable inside Vim (which points to python 3) to start ycmd, and that explodes.

@micbou @puremourning @vheon I'm looking for ideas on how best to address this, because we really must.

@linghutf

This comment has been minimized.

Copy link

commented Apr 24, 2016

It' also occur this problem in my ubuntu16.04,but no one else solve the problem yet.

@micbou

This comment has been minimized.

Copy link
Collaborator

commented Apr 24, 2016

@linghutf Did you try to set the g:ycm_server_python_interpreter option to /usr/bin/python in your .vimrc?

let g:ycm_server_python_interpreter = '/usr/bin/python'
@ehzawad

This comment has been minimized.

Copy link

commented Apr 24, 2016

As @Valloric says
/usr/bin/python3 install.py args
works like a charm
let g:ycm_server_python_interpreter = '/usr/bin/python3' works well with me in Ubuntu Xenial Xerus....

@linghutf

This comment has been minimized.

Copy link

commented Apr 25, 2016

@micbou @ehzShelter Are you sure?My environment is Ubuntu16.04 Desktop,The default python is python2.After adding the script in vimrc,problem hasn't be solved.

@micbou

This comment has been minimized.

Copy link
Collaborator

commented Apr 25, 2016

Could you run the command :YcmToggleLogs stderr in Vim and paste the contents of the logfile?

@ehzawad

This comment has been minimized.

Copy link

commented Apr 25, 2016

@linghutf ...Surely without any issue.. I have also run :YcmToggleLogs stderr
No error...!!
Make sure you have installed python3-dev

sudo apt-get install python3-dev

This is required to run install.py script via python3 interpreter

For confirmation >>
ycm

@linghutf

This comment has been minimized.

Copy link

commented Apr 25, 2016

@ehzShelter This is my config:

  • python3-dev
    1
  • environment
    2
  • vimrc config
    3
  • still occur this problem ̄へ ̄
    4
@iamsebastian

This comment has been minimized.

Copy link

commented Apr 25, 2016

Just as a hint for other Ubuntu users: If you run into errors, while using the trivial fix of @Valloric:

python3 install.py <args>

, do not forget to install the python3-dev package, with:

sudo apt-get install python3-dev
Valloric added a commit that referenced this issue Apr 26, 2016
Note: depends on ycm-core/ycmd#466 being merged and the ycmd submodule
ref then being updated.

Fixes #2136
Valloric added a commit that referenced this issue Apr 26, 2016
Note: depends on ycm-core/ycmd#466 being merged and the ycmd submodule
ref then being updated.

Fixes #2136
Valloric added a commit that referenced this issue Apr 26, 2016
Note: depends on ycm-core/ycmd#466 being merged and the ycmd submodule
ref then being updated.

Fixes #2136
Valloric added a commit that referenced this issue Apr 26, 2016
Note: depends on ycm-core/ycmd#466 being merged and the ycmd submodule
ref then being updated.

Fixes #2136
@chenshuxian1997

This comment has been minimized.

Copy link

commented Apr 27, 2016

mine is 16.04 it said the runit can't work,and the report shows everytime when i use the command of dpkg.i am a green hand in linux and language.don't know how to do.

homu added a commit to ycm-core/ycmd that referenced this issue Apr 27, 2016
[READY] Storing path to Python used in build.py

We'll use this in YCM to ensure we start ycmd with the same version of
Python that was used for building the C++ libraries loaded into ycmd.

Related to ycm-core/YouCompleteMe#2136

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/ycmd/466)
<!-- Reviewable:end -->
Valloric added a commit that referenced this issue Apr 28, 2016
Note: depends on ycm-core/ycmd#466 being merged and the ycmd submodule
ref then being updated.

Fixes #2136
homu added a commit that referenced this issue Apr 28, 2016
[READY] Starting ycmd with Python used to build it

Note: depends on ycm-core/ycmd#466 being merged and the ycmd submodule
ref then being updated.

Fixes #2136

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2140)
<!-- Reviewable:end -->
@homu homu closed this in #2140 Apr 28, 2016
@BigfootN

This comment has been minimized.

Copy link

commented Apr 29, 2016

Hello,

I am running Archlinux and I am still having the same problem even though I tried setting the g:ycm_python_binary_path to:

/usr/bin/python
and
/usr/bin/python2
and
/usr/bin/python3

I installed ycm_core by compiling it with the full installation guide:

cmake -G "Unix Makefiles" -DEXTERNAL_LIBCLANG_PATH=/usr/lib/libclang.so . ~/.config/nvim/plugged/YouCompleteMe/third_party/ycmd/cpp

Thank you very much in advance for any help.

@micbou

This comment has been minimized.

Copy link
Collaborator

commented Apr 29, 2016

This is not the g:ycm_python_binary_path option but the g:ycm_server_python_interpreter one.

@BigfootN

This comment has been minimized.

Copy link

commented Apr 29, 2016

Oh sorry thank you

@starrysl

This comment has been minimized.

Copy link

commented May 2, 2016

I followed @micbou 's instruction to set g:ycm_server_python_interpreter and it works for my Python 2 environment on 16.04!

@chenshuxian1997

This comment has been minimized.

Copy link

commented May 10, 2016

well actually i klone another vimrc from my friend and i wonder if i still use yours will it cause problems anyway i just want to remove
and also my system has reported errror i don't know whether it is nessary to solve it. and how
green hand is hard to work on not only on vimrc and system but github
maybe it's not suit me

@starrysl

This comment has been minimized.

Copy link

commented May 10, 2016

@chenshuxian1997 I don't understand what you mean. Could you write in Chinese instead?

@abhisheksambyal

This comment has been minimized.

Copy link

commented May 18, 2016

@linghutf, @micbou solution works!
Put this in your .vimrc: let g:ycm_server_python_interpreter = '/usr/bin/python'
$ git clone https://github.com/Valloric/YouCompleteMe.git
$ git checkout -> master(default)
$ ./install.py <args>

@chenshuxian1997

This comment has been minimized.

Copy link

commented Jun 3, 2016

@starrysl 看样子我的英语真的很差...言归正传,就是我后来用了朋友vim配置,导致每次更新都会显示runit没配置,后来我就直接手动找到文件路径删除文件夹,应该没问题吧

@Thilo1

This comment has been minimized.

Copy link

commented Oct 14, 2016

Hello!
Why is this issue closed? It is not working out of the box. I run Ubuntu 16.04. I got the Error in the log: ERROR - ycm_core library compiled for Python 2 but loaded in Python 3.
This issue -at least- should be properly reflected in the installation guide. Which it is not.

Greetings

@vheon

This comment has been minimized.

Copy link
Collaborator

commented Oct 14, 2016

log: ERROR - ycm_core library compiled for Python 2 but loaded in Python 3.

@Thilo1 should we be more specific? I mean the error is telling you what is happening 😕

@Thilo1

This comment has been minimized.

Copy link

commented Oct 14, 2016

I am not complaining about the specifity of the error message 😉. My wish would be more verbosity.

Good Knight

Diese Nachricht wurde von meinem Android Mobiltelefon mit GMX Mail gesendet.Am 14.10.16, 23:41, Andrea Cedraro notifications@github.com schrieb:

    log: ERROR - ycm_core library compiled for Python 2 but loaded in Python 3.



  @Thilo1 should we be more specific? I mean the error is telling you what is happening 😕


  —
  You are receiving this because you were mentioned.
  Reply to this email directly, view it on GitHub, or mute the thread.
@micbou

This comment has been minimized.

Copy link
Collaborator

commented Oct 14, 2016

@Thilo1 Did you use the install.py script to install YCM? Are you seeing this message

The ycmd server SHUT DOWN (restart with ':YcmRestartServer'). YCM core library compiled for Python 2 but loaded in Python 3. Set the 'g:ycm_server_python_interpreter' option to a Python 2 interpreter path.

in Vim?

@Thilo1

This comment has been minimized.

Copy link

commented Oct 14, 2016

No i didn't use the install.py. Took the other way with direct cmake call.

Diese Nachricht wurde von meinem Android Mobiltelefon mit GMX Mail gesendet.Am 15.10.16, 00:12, micbou notifications@github.com schrieb:

  @Thilo1 Did you use the install.py script to install YCM? Are you seeing this message



    The ycmd server SHUT DOWN (restart with ':YcmRestartServer'). YCM core library compiled for Python 2 but loaded in Python 3. Set the 'g:ycm_server_python_interpreter' option to a Python 2 interpreter path.



  in Vim?


  —
  You are receiving this because you were mentioned.
  Reply to this email directly, view it on GitHub, or mute the thread.
@vheon

This comment has been minimized.

Copy link
Collaborator

commented Oct 15, 2016

@Thilo1 use the install.py script, is easier and more errorproof. @micbou I think you were right and we should move the "Full installation guide" as a last resort thing 😕

@michaelachrisco

This comment has been minimized.

Copy link

commented Nov 18, 2016

Same issue as above. Had to explicitly use python3 (as others suggested) in order to get the install script working:

python3 ./install.py --clang-completer

Python2 generated a compilation error.

Also make sure to add to your .vimrc file:

let g:ycm_server_python_interpreter = '/usr/bin/python3'
@hui00

This comment has been minimized.

Copy link

commented Aug 6, 2017

@michaelachrisco thank you very much! i tried it all day... now it works.

@chenynCV

This comment has been minimized.

Copy link

commented Aug 14, 2017

@michaelachrisco thank you very much! i tried it for nearly 2 hours... now it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.