Youcompleteme: How to compile ycm with a specific python library?

Created on 8 Mar 2016  Â·  4Comments  Â·  Source: ycm-core/YouCompleteMe

On my computer, the default python is installed via pyenv, and I want ycm to compile its server with this python's library.

The path of python is:

/home/user/.pyenv/versions/2.7.11

When I compile ycm's server, cmake dumps:

CMake Error at /home/user/.linuxbrew/Cellar/cmake/3.4.3/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
  Could NOT find PythonLibs (missing: PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS)
  (Required is at least version "2.6")
Call Stack (most recent call first):
  /home/user/.linuxbrew/Cellar/cmake/3.4.3/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE)
 /home/user/.linuxbrew/Cellar/cmake/3.4.3/share/cmake/Modules/FindPythonLibs.cmake:264 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:204 (find_package)

It seems due to that cmake can not find the correct library and header. How to set the correct path for cmake?

Most helpful comment

Thanks, I finally got YCM working with my Python 3 project!

Just in case someone else runs into this and to help @d0u9: I followed this guide, and at step four, for the first of two commands, I ran this:

cmake -G "Unix Makefiles" ~/.vim/plugged/YouCompleteMe/third_party/ycmd/cpp/ -DPYTHON_INCLUDE_DIR=/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m/ -DPYTHON_LIBRARY=/Library/Frameworks/Python.framework/Versions/3.5/lib/libpython3.5.dylib -DUSE_PYTHON2=OFF

Obviously, @d0u9 needs to remove the -DUSE_PYTHON2 flag because he's running 2.7. Hope this helps!

All 4 comments

I also ran into this issue when trying to compile ycmd using Python 3. When running python3.5 build.py inside third_party/ycmd, I got the same error:

CMake Error at /usr/local/Cellar/cmake/3.4.3/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
  Could NOT find PythonLibs: Found unsuitable version "2.7.10", but required
  is at least "3.3" (found
  /System/Library/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib)
Call Stack (most recent call first):
  /usr/local/Cellar/cmake/3.4.3/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:386 (_FPHSA_FAILURE_MESSAGE)
  /usr/local/Cellar/cmake/3.4.3/share/cmake/Modules/FindPythonLibs.cmake:264 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:214 (find_package)

See the FAQ for info on how to force the use of specific Python versions. (There are CMake vars you can set.)

Also, please don't delete our issue template.

Thanks, I finally got YCM working with my Python 3 project!

Just in case someone else runs into this and to help @d0u9: I followed this guide, and at step four, for the first of two commands, I ran this:

cmake -G "Unix Makefiles" ~/.vim/plugged/YouCompleteMe/third_party/ycmd/cpp/ -DPYTHON_INCLUDE_DIR=/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m/ -DPYTHON_LIBRARY=/Library/Frameworks/Python.framework/Versions/3.5/lib/libpython3.5.dylib -DUSE_PYTHON2=OFF

Obviously, @d0u9 needs to remove the -DUSE_PYTHON2 flag because he's running 2.7. Hope this helps!

Thanks, I finally got YCM working with my Python 3 project!

@Gwildor If all you wanted was completion for a Python3 project you don't have to compile ycmd using Python3, just set the right options: https://github.com/Valloric/YouCompleteMe#python-semantic-completion

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hackrole picture hackrole  Â·  3Comments

Jzarecta picture Jzarecta  Â·  4Comments

vbextreme picture vbextreme  Â·  4Comments

pprzetacznik picture pprzetacznik  Â·  4Comments

tgzhou98 picture tgzhou98  Â·  3Comments