Cmake not finding the Python libraries

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Cmake not finding the Python libraries

Dimitrova, Maria


I am trying to compile a program based on a setup script calling Cmake but I end up with a strange situation where it complains that it cannot find PYTHON_LIBRARIES and PYTHON_INCLUDE_DIRS. I double checked that indeed "which python" returns the one from Anaconda, and that all the environmental variables for it are exported:

export PATH=/MYPATH/anaconda2/bin:${PATH}
export PYTHON_LIBRARY=/MYPATH/anaconda2/lib/
export PYTHON_INCLUDE_DIR=/MYPATH/anaconda2/include/python2.7
export PYTHON_LIBRARIES="/MYPATH/anaconda2/lib/"
export PYTHON_INCLUDE_DIRS="/MYPATH/anaconda2/include/python2.7"
export PYTHON_EXECUTABLE="/MYPATH/anaconda2/bin/python"

(MYPATH stands for my home directory in this email)

"echo $PYTHON_LIBRARIES" and "echo $PYTHON_INCLUDE_DIRS" are giving the correct paths, as well. 

Cmake is evoked through a ./setup script which can also accept the following arguments:
  --cmake-executable=<CMAKE_EXECUTABLE>  Set the CMake executable [default: cmake].
  --cmake-options=<STRING>               Define options to CMake [default: ''].

and I have tried passing the variables there:

./setup --fc=ifort --extra-fc-flags='-xAVX -axCORE-AVX2,CORE-AVX-I' --cc=icc --extra-cc-flags='-xAVX -axCORE-AVX2,CORE-AVX-I' --cxx=icc --extra-cxx-flags='-xAVX -axCORE-AVX2,CORE-AVX-I' --cmake-options='-DPYTHON_LIBRARIES=/MYPATH/anaconda2/lib/ -DPYTHON_INCLUDE_DIRS=/MYPATH/anaconda2/include/python2.7'

Yet it crashes with the following output:

CMake Error at /MYPATH/cmake-3.9.4-Linux-x86_64/share/cmake-3.9/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  (Required is at least version "2.7")
Call Stack (most recent call first):
  /MYPATHcmake-3.9.4-Linux-x86_64/share/cmake-3.9/Modules/FindPackageHandleStandardArgs.cmake:377 (_FPHSA_FAILURE_MESSAGE)
  /MYPATH/cmake-3.9.4-Linux-x86_64/share/cmake-3.9/Modules/FindPythonLibs.cmake:262 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:23 (find_package)

Could the problem be caused by a bug in the setup script or something that I have misunderstood about Cmake?

Best regards,



Powered by

Please keep messages on-topic and check the CMake FAQ at:

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support:
CMake Consulting:
CMake Training Courses:

Visit other Kitware open-source projects at

Follow this link to subscribe/unsubscribe: