CMake can not find PythonLibs
I am trying to build inria Graphite on my ubuntu which is running in a VirtualBox simulator, I follow the instructions, and install the python-dev packages, but when I run cmake , still got an error:
CMake Error at /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:108 (message): Could NOT find PythonLibs (missing: PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS) (Required is at least version "3.2") Call Stack (most recent call first): /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:315 (_FPHSA_FAILURE_MESSAGE) /usr/share/cmake-2.8/Modules/FindPythonLibs.cmake:208 (FIND_PACKAGE_HANDLE_STANDARD_ARGS) src/packages/OGF/gel_python3/CMakeLists.txt:11 (FIND_PACKAGE)
tintin@tintin-VirtualBox:/usr/lib$ find . -name "libpython*" ./x86_64-linux-gnu/libpython3.4m.so.1.0 ./x86_64-linux-gnu/libpython2.7.so.1.0 ./x86_64-linux-gnu/libpython3.4m.a ./x86_64-linux-gnu/libpython2.7.a ./x86_64-linux-gnu/libpython3.4m.so ./x86_64-linux-gnu/libpython2.7.so ./x86_64-linux-gnu/libpython2.7.so.1 ./x86_64-linux-gnu/libpython3.4m.so.1
4 Answers 4
Installing python-dev actually fixed this for me:
sudo apt-get install python-dev
Rather than pointing to an external link please copy-paste the relevant portion from there so that if the link is unreachable for some reason the contents are still available here..
A small note: for Python 3 use apt-get install python3-dev . python-dev and python3-dev are metapackages that pull the most current dev upstream for the selected Python.
The problem seems to be that Ubuntu 14.04 installs Python 3.4 by default and the CMake version from Ubuntu (2.8) only searches up to Python 3.3. A workaround is to add set(Python_ADDITIONAL_VERSIONS 3.4) before the find_package statement. Note that I filed a bug about this issue.
Since CMake 3.0, CMake searches up to Python 3.4, so installing that version manually should also fix the problem.
For me the issue was a bad cache
Removed the cache with the old 2.7 version and allowed it to find 3.2 in my case.
find_package(PythonInterp 3.2 REQUIRED) find_package(PythonLibs 3.2 REQUIRED) message(STATUS "PYTHON_LIBRARIES = $") message(STATUS "PYTHON_EXECUTABLE = $") message(STATUS "PYTHON_INCLUDE_DIRS = $") . include_directories($)
I recently had a similar issue with Ubuntu 14.04 64-bit; apparently, CMake does not look into architecture dependent install folders by default:
CMake constructs a set of possible installation prefixes for the package. Under each prefix several directories are searched for a configuration file. The tables below show the directories searched. [. ] /(lib/|lib|share)/cmake/*/ (U) /(lib/|lib|share)/*/ (U) /(lib/|lib|share)/*/(cmake|CMake)/ (U) [. ] In all cases the is treated as case-insensitive and corresponds to any of the names specified ( or names given by NAMES). Paths with lib/ are enabled if CMAKE_LIBRARY_ARCHITECTURE is set.
(from CMake 2.8.12 online documentation of the find_package command)
A solution consists in setting this CMAKE_LIBRARY_ARCHITECTURE in the project root CMakeLists.txt file (in your case that would be editing src/packages/OGF/gel_python3/CMakeLists.txt) before calling find_package for PythonLibs; for instance:
cmake_minimum_required(VERSION 2.8) project(project_name) # Check the architecture and set CMAKE_LIBRARY_ARCHITECTURE accordingly if(UNIX) if(CMAKE_SIZEOF_VOID_P EQUAL 8) set(CMAKE_LIBRARY_ARCHITECTURE "x86_64-linux-gnu") endif() endif() find_package(PythonInterp 3.2 REQUIRED) find_package(PythonLibs 3.2 REQUIRED) # Rest of your file
CMake could NOT find Python
CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message): Could NOT find Python (missing: Python_EXECUTABLE Python_LIBRARIES Python_INCLUDE_DIRS Interpreter Development) Call Stack (most recent call first): /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE) /usr/share/cmake-3.16/Modules/FindPython.cmake:347 (find_package_handle_standard_args) cmake/modules/SearchRootCoreDeps.cmake:70 (find_package) CMakeLists.txt:120 (include)
The following packages have unmet dependencies: python-dev-is-python2 : Depends: python-is-python2 (= 2.7.17-4) but it is not going to be installed Depends: python2-dev but it is not going to be installed root-system : Depends: root-system-bin but it is not installable Depends: libroot-core-dev but it is not installable Recommends: libroot-graf3d-gl-dev (>= 5.34.30-0ubuntu8) but it is not installable Recommends: libroot-io-xmlparser-dev (>= 5.34.30-0ubuntu8) but it is not installable Recommends: libroot-math-mathmore-dev (>= 5.34.30-0ubuntu8) but it is not installable Recommends: libroot-math-unuran-dev (>= 5.34.30-0ubuntu8) but it is not installable Recommends: libroot-misc-memstat-dev (>= 5.34.30-0ubuntu8) but it is not installable Recommends: libroot-misc-table-dev (>= 5.34.30-0ubuntu8) but it is not installable Recommends: libroot-net-bonjour-dev (>= 5.34.30-0ubuntu8) but it is not installable Recommends: libroot-net-ldap-dev (>= 5.34.30-0ubuntu8) but it is not installable Recommends: root-plugin-graf2d-asimage (>= 5.34.30-0ubuntu8) but it is not installable Recommends: root-plugin-gui-qt (>= 5.34.30-0ubuntu8) but it is not installable Recommends: root-plugin-graf2d-qt (>= 5.34.30-0ubuntu8) but it is not installable Recommends: root-plugin-math-fftw3 (>= 5.34.30-0ubuntu8) but it is not installable Recommends: root-plugin-math-minuit2 (>= 5.34.30-0ubuntu8) but it is not installable Recommends: root-plugin-net-krb5 (>= 5.34.30-0ubuntu8) but it is not installable Recommends: root-plugin-sql-odbc (>= 5.34.30-0ubuntu8) but it is not installable Recommends: libroot-geom-dev (>= 5.34.30-0ubuntu8) but it is not installable Recommends: libroot-graf2d-gpad-dev (>= 5.34.30-0ubuntu8) but it is not installable Recommends: libroot-graf2d-graf-dev (>= 5.34.30-0ubuntu8) but it is not installable Recommends: libroot-graf2d-postscript-dev (>= 5.34.30-0ubuntu8) but it is not installable Recommends: libroot-graf3d-eve-dev (>= 5.34.30-0ubuntu8) but it is not installable Recommends: libroot-graf3d-g3d-dev (>= 5.34.30-0ubuntu8) but it is not installable Recommends: libroot-gui-dev (>= 5.34.30-0ubuntu8) but it is not installable Recommends: libroot-gui-ged-dev (>= 5.34.30-0ubuntu8) but it is not installable Recommends: libroot-hist-dev (>= 5.34.30-0ubuntu8) but it is not installable Recommends: libroot-hist-spectrum-dev (>= 5.34.30-0ubuntu8) but it is not installable Recommends: libroot-html-dev (>= 5.34.30-0ubuntu8) but it is not installable Recommends: libroot-io-dev (>= 5.34.30-0ubuntu8) but it is not installable Recommends: libroot-math-foam-dev (>= 5.34.30-0ubuntu8) but it is not installable Recommends: libroot-math-genvector-dev (>= 5.34.30-0ubuntu8) but it is not installable Recommends: libroot-math-mathcore-dev (>= 5.34.30-0ubuntu8) but it is not installable Recommends: libroot-math-matrix-dev (>= 5.34.30-0ubuntu8) but it is not installable Recommends: libroot-math-minuit-dev (>= 5.34.30-0ubuntu8) but it is not installable Recommends: libroot-math-mlp-dev (>= 5.34.30-0ubuntu8) but it is not installable Recommends: libroot-math-physics-dev (>= 5.34.30-0ubuntu8) but it is not installable Recommends: libroot-math-quadp-dev (>= 5.34.30-0ubuntu8) but it is not installable Recommends: libroot-math-smatrix-dev (>= 5.34.30-0ubuntu8) but it is not installable Recommends: libroot-math-splot-dev (>= 5.34.30-0ubuntu8) but it is not installable Recommends: libroot-misc-minicern-dev (>= 5.34.30-0ubuntu8) but it is not installable Recommends: libroot-montecarlo-eg-dev (>= 5.34.30-0ubuntu8) but it is not installable Recommends: libroot-montecarlo-vmc-dev (>= 5.34.30-0ubuntu8) but it is not installable Recommends: libroot-net-dev (>= 5.34.30-0ubuntu8) but it is not installable Recommends: libroot-net-auth-dev (>= 5.34.30-0ubuntu8) but it is not installable Recommends: libroot-proof-dev (>= 5.34.30-0ubuntu8) but it is not installable Recommends: libroot-proof-proofplayer-dev (>= 5.34.30-0ubuntu8) but it is not installable Recommends: libroot-tmva-dev (>= 5.34.30-0ubuntu8) but it is not installable Recommends: libroot-tree-dev (>= 5.34.30-0ubuntu8) but it is not installable Recommends: libroot-tree-treeplayer-dev (>= 5.34.30-0ubuntu8) but it is not installable Recommends: root-plugin-geom-geombuilder (>= 5.34.30-0ubuntu8) but it is not installable Recommends: root-plugin-geom-geompainter (>= 5.34.30-0ubuntu8) but it is not installable Recommends: root-plugin-graf2d-x11 (>= 5.34.30-0ubuntu8) but it is not installable Recommends: root-plugin-graf3d-x3d (>= 5.34.30-0ubuntu8) but it is not installable Recommends: root-plugin-gui-fitpanel (>= 5.34.30-0ubuntu8) but it is not installable Recommends: root-plugin-gui-guibuilder (>= 5.34.30-0ubuntu8) but it is not installable Recommends: root-plugin-gui-sessionviewer (>= 5.34.30-0ubuntu8) but it is not installable Recommends: root-plugin-hist-hbook (>= 5.34.30-0ubuntu8) but it is not installable Recommends: root-plugin-hist-histpainter (>= 5.34.30-0ubuntu8) but it is not installable Recommends: root-plugin-hist-spectrumpainter (>= 5.34.30-0ubuntu8) but it is not installable Recommends: root-plugin-io-sql (>= 5.34.30-0ubuntu8) but it is not installable Recommends: root-plugin-io-xml (>= 5.34.30-0ubuntu8) but it is not installable Recommends: root-plugin-math-fumili (>= 5.34.30-0ubuntu8) but it is not installable Recommends: root-plugin-tree-treeviewer (>= 5.34.30-0ubuntu8) but it is not installable Recommends: root-system-proofd (>= 5.34.30-0ubuntu8) but it is not installable Recommends: root-system-rootd (>= 5.34.30-0ubuntu8) but it is not installable Recommends: root-system-doc (>= 5.34.30-0ubuntu8) but it is not installable E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).