Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cmake Could NOT find PythonLibs

I'm trying to download YouCompleteMe for Vim on Windows following this tutorial.

When calling CMake:

cmake -G "Visual Studio 14 Win64" -DPATH_TO_LLVM_ROOT=%USERPROFILE%/ycm_temp/llvm_root_dir . %USERPROFILE%/vimfiles/bundle/YouCompleteMe/third_party/ycmd/cpp

It throws the following exception:

CMake Error at C:/Program Files/CMake/share/cmake-3.9/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find PythonLibs (missing: PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS)
(Required is at least version "2.6")
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.9/Modules/FindPackageHandleStandardArgs.cmake:377 (_FPHSA_FAILURE_MESSAGE)
C:/Program Files/CMake/share/cmake-3.9/Modules/FindPythonLibs.cmake:262 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:189 (find_package)

I have installed python-2.7.13, and put it under PATH in Environment Variables.

What should I do to fix the exception?

like image 351
J3soon Avatar asked Dec 06 '25 05:12

J3soon


1 Answers

Instead of using:

cmake -G "Visual Studio 14 Win64" -DPATH_TO_LLVM_ROOT=%USERPROFILE%/ycm_temp/llvm_root_dir . %USERPROFILE%/vimfiles/bundle/YouCompleteMe/third_party/ycmd/cpp

You should set the DPYTHON_INCLUDE_DIR and DPYTHON_LIBRARY flags to something like below:

-DPYTHON_INCLUDE_DIR=C:\Python27\include \
-DPYTHON_LIBRARY=C:\Python27\libs

If you use the default install path (C:\Python27), the full command is shown below:

cmake -G "Visual Studio 14 Win64" -DPATH_TO_LLVM_ROOT=%USERPROFILE%/ycm_temp/llvm_root_dir . %USERPROFILE%/vimfiles/bundle/YouCompleteMe/third_party/ycmd/cpp -DPYTHON_INCLUDE_DIR=C:\Python27\include -DPYTHON_LIBRARY=C:\Python27\libs
like image 84
J3soon Avatar answered Dec 08 '25 18:12

J3soon