Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cmake is not able to find Python-libraries

Getting this error:

sudo: unable to resolve host coderw@ll -- Could NOT find PythonLibs (missing:  PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS)  CMake Error at /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:108      (message): Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE) Call Stack (most recent call first): /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:315   (_FPHSA_FAILURE_MESSAGE) /usr/share/cmake-2.8/Modules/FindPythonInterp.cmake:139  (FIND_PACKAGE_HANDLE_STANDARD_ARGS) Code/cmake/Modules/FindNumPy.cmake:10 (find_package) CMakeLists.txt:114 (find_package)    -- Configuring incomplete, errors occurred! See also "/home/coderwall/Desktop/rdkit/build/CMakeFiles/CMakeOutput.log". See also "/home/coderwall/Desktop/rdkit/build/CMakeFiles/CMakeError.log". 

I have already installed:

  1. sudo apt-get install python-dev
  2. Environment variable are already set as follow:

    PYTHON_INCLUDE_DIRS=/usr/include/python2.7  PYTHON_LIBRARIES=/usr/lib/python2.7/config/libpython2.7.so 

Location of python.h : /usr/lib/include/python2.7/python.h

Location of python libs: /usr/lib/python2.7/ How to solve this?

like image 827
Amit Pal Avatar asked Jun 11 '14 23:06

Amit Pal


1 Answers

You can fix the errors by appending to the cmake command the -DPYTHON_LIBRARY and -DPYTHON_INCLUDE_DIR flags filled with the respective folders.

Thus, the trick is to fill those parameters with the returned information from the python interpreter, which is the most reliable. This may work independently of your python location/version (also for Anaconda users):

$ cmake .. \ -DPYTHON_INCLUDE_DIR=$(python -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())")  \ -DPYTHON_LIBRARY=$(python -c "import distutils.sysconfig as sysconfig; print(sysconfig.get_config_var('LIBDIR'))") 

If the version of python that you want to link against cmake is Python3.X and the default python symlink points to Python2.X, python3 -c ... can be used instead of python -c ....

In case that the error persists, you may need to update the cmake to a higher version as stated by @pdpcosta and repeat the process again.

like image 119
Ivan De Paz Centeno Avatar answered Sep 28 '22 10:09

Ivan De Paz Centeno