Python_LIBRARY in CMake NotFound - python

I'm trying to build the open-source software LMGC90 (https://git-xen.lmgc.univ-montp2.fr/lmgc90/lmgc90_user/-/wikis/compilation) and I have a trouble when I try to use the command >cmake. Details are below:
CMake Error: The following variables are used in this project, but
they are set to NOTFOUND. Please set them or make sure they are set
and tested correctly in the CMake files: PYTHON_LIBRARY
linked by target "ann_manh" in directory /home/tphan/lmgc90_user_2021.rc1/src/contribs/ann-1.1.2/wrap
linked by target "ann_eucl" in directory /home/tphan/lmgc90_user_2021.rc1/src/contribs/ann-1.1.2/wrap
linked by target "lmgc90" in directory /home/tphan/lmgc90_user_2021.rc1/src/ChiPy
The full error message is:
tphan#tphan-XPS-15-9570:~/lmgc90_user_2021.rc1/build$ cmake .. -DPYTHON_EXECUTABLE=/usr/bin/python3
-- You try to build LMGC90_dev
fatal: not a git repository (or any of the parent directories): .git
-- Building git branch
-- A library with LAPACK API found.
-- Found Python executable: /usr/bin/python3.8
-- Found Python library: PYTHON_LIBRARY-NOTFOUND
-- Python version is : 3.8.10
-- Python include dir is : /usr/include/python3.8
-- Cython not found... deactivate rTree Python binding
-- Matlib Library used : /home/tphan/lmgc90_user_2021.rc1/build/lib/libmatlib.so
-- Sparse linear algebra include path found: /home/tphan/lmgc90_user_2021.rc1/build/include
-- Sparse linear algebra libraries found: /home/tphan/lmgc90_user_2021.rc1/build/lib/libdmumps.so
-- Sparse linear algebra binding found: /home/tphan/lmgc90_user_2021.rc1/src/contribs/Mumps_SparseLinearAlgebra.f90
-- matlib library : /home/tphan/lmgc90_user_2021.rc1/build/lib/libmatlib.so
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
PYTHON_LIBRARY
linked by target "ann_manh" in directory /home/tphan/lmgc90_user_2021.rc1/src/contribs/ann-1.1.2/wrap
linked by target "ann_eucl" in directory /home/tphan/lmgc90_user_2021.rc1/src/contribs/ann-1.1.2/wrap
linked by target "lmgc90" in directory /home/tphan/lmgc90_user_2021.rc1/src/ChiPy
-- Configuring incomplete, errors occurred!
See also "/home/tphan/lmgc90_user_2021.rc1/build/CMakeFiles/CMakeOutput.log".
See also "/home/tphan/lmgc90_user_2021.rc1/build/CMakeFiles/CMakeError.log".```
Do you know how I can fix this?

You must specify the path to the Python library as:
cmake .. -DPYTHON_EXECUTABLE=/usr/bin/python3 -DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.8.so

Related

__main__ module not found in em package while installing ROS

I am trying to install ROS Noetic. I am stuck at the "catkin_make install" step. While trying to execute the above command, I am getting the following error.
command line catkin_make
The error that I am getting
-- Using CMAKE_PREFIX_PATH: /opt/ros/noetic;/home/anant/ros2_foxy/install/yaml_cpp_vendor;/home/anant/ros2_foxy/install/ament_cmake_uncrustify;/home/anant/ros2_foxy/install/uncrustify_vendor;/home/anant/ros2_foxy/install/tracetools;/home/anant/ros2_foxy/install/tinyxml2_vendor;/home/anant/ros2_foxy/install/qt_gui;/home/anant/ros2_foxy/install/tango_icons_vendor;/home/anant/ros2_foxy/install/spdlog_vendor;/home/anant/ros2_foxy/install/rosidl_typesupport_interface;/home/anant/ros2_foxy/install/rosidl_generator_dds_idl;/home/anant/ros2_foxy/install/rosidl_cmake;/home/anant/ros2_foxy/install/rosidl_parser;/home/anant/ros2_foxy/install/rosidl_adapter;/home/anant/ros2_foxy/install/rmw_implementation_cmake;/home/anant/ros2_foxy/install/python_qt_binding;/home/anant/ros2_foxy/install/launch_testing_ament_cmake;/home/anant/ros2_foxy/install/python_cmake_module;/home/anant/ros2_foxy/install/osrf_testing_tools_cpp;/home/anant/ros2_foxy/install/ament_cmake_ros;/home/anant/ros2_foxy/install/ament_cmake_gmock;/home/anant/ros2_foxy/install/gmock_vendor;/home/anant/ros2_foxy/install/ament_cmake_gtest;/home/anant/ros2_foxy/install/gtest_vendor;/home/anant/ros2_foxy/install/ament_cmake_google_benchmark;/home/anant/ros2_foxy/install/google_benchmark_vendor;/home/anant/ros2_foxy/install/foonathan_memory_vendor;/home/anant/ros2_foxy/install/fastrtps_cmake_module;/home/anant/ros2_foxy/install/fastcdr;/home/anant/ros2_foxy/install/eigen3_cmake_module;/home/anant/ros2_foxy/install/cyclonedds;/home/anant/ros2_foxy/install/connext_cmake_module;/home/anant/ros2_foxy/install/ament_cmake_xmllint;/home/anant/ros2_foxy/install/ament_cmake_pep257;/home/anant/ros2_foxy/install/ament_lint_auto;/home/anant/ros2_foxy/install/ament_cmake;/home/anant/ros2_foxy/install/ament_cmake_version;/home/anant/ros2_foxy/install/ament_cmake_pytest;/home/anant/ros2_foxy/install/ament_cmake_lint_cmake;/home/anant/ros2_foxy/install/ament_cmake_flake8;/home/anant/ros2_foxy/install/ament_cmake_cpplint;/home/anant/ros2_foxy/install/ament_cmake_cppcheck;/home/anant/ros2_foxy/install/ament_cmake_copyright;/home/anant/ros2_foxy/install/ament_cmake_test;/home/anant/ros2_foxy/install/ament_cmake_target_dependencies;/home/anant/ros2_foxy/install/ament_cmake_python;/home/anant/ros2_foxy/install/ament_cmake_export_dependencies;/home/anant/ros2_foxy/install/ament_cmake_libraries;/home/anant/ros2_foxy/install/ament_cmake_include_directories;/home/anant/ros2_foxy/install/ament_cmake_export_targets;/home/anant/ros2_foxy/install/ament_cmake_export_link_flags;/home/anant/ros2_foxy/install/ament_cmake_export_interfaces;/home/anant/ros2_foxy/install/ament_cmake_export_libraries;/home/anant/ros2_foxy/install/ament_cmake_export_include_directories;/home/anant/ros2_foxy/install/ament_cmake_export_definitions;/home/anant/ros2_foxy/install/ament_cmake_core;/home/anant/ros2_foxy/install/ament_index_cpp
-- This workspace overlays: /opt/ros/noetic
-- Found PythonInterp: /home/anant/anaconda3/bin/python3 (found suitable version "3.8.5", minimum required is "3")
-- Using PYTHON_EXECUTABLE: /home/anant/anaconda3/bin/python3
-- Using Debian Python package layout
-- Using empy: /home/anant/anaconda3/lib/python3.8/site-packages/em
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/anant/catkin_ws/src/test_results
-- Forcing gtest/gmock from source, though one was otherwise available.
-- Found gtest sources under '/usr/src/googletest': gtests will be built
-- Found gmock sources under '/usr/src/googletest': gmock will be built
-- Found PythonInterp: /home/anant/anaconda3/bin/python3 (found version "3.8.5")
-- Using Python nosetests: /usr/bin/nosetests3
-- catkin 0.8.9
-- BUILD_SHARED_LIBS is on
-- BUILD_SHARED_LIBS is on
/home/anant/anaconda3/bin/python3: can't find '__main__' module in '/home/anant/anaconda3/lib/python3.8/site-packages/em'
CMake Error at /opt/ros/noetic/share/catkin/cmake/safe_execute_process.cmake:11 (message):
execute_process(/home/anant/catkin_ws/src/catkin_generated/env_cached.sh
"/home/anant/anaconda3/bin/python3"
"/home/anant/anaconda3/lib/python3.8/site-packages/em" "--raw-errors" "-F"
"/home/anant/catkin_ws/src/catkin_generated/order_packages.py" "-o"
"/home/anant/catkin_ws/src/catkin_generated/order_packages.cmake"
"/opt/ros/noetic/share/catkin/cmake/em/order_packages.cmake.em") returned
error code 1
Call Stack (most recent call first):
/opt/ros/noetic/share/catkin/cmake/em_expand.cmake:25 (safe_execute_process)
/opt/ros/noetic/share/catkin/cmake/catkin_workspace.cmake:35 (em_expand)
CMakeLists.txt:69 (catkin_workspace)
-- Configuring incomplete, errors occurred!
See also "/home/anant/catkin_ws/src/CMakeFiles/CMakeOutput.log".
See also "/home/anant/catkin_ws/src/CMakeFiles/CMakeError.log".
link to the tutorial I am following
http://wiki.ros.org/catkin/commands/catkin_make
It would be very helpful if someone could help me in this regards
Thanks in Advance!!
I had this problem because I have anaconda installed.
The catkin was looking for the package in: /home/leandro/anaconda3/lib/python3.8/site-packages/
after uninstalling them from the current and sudo users with
pip uninstall em empy and
sudo pip uninstall em empy
catkin was able to find the correct em and empy packages at /usr/lib/python3/dist-packages/em.py
I am afraid there is an nice spaghetti in my system right now, but the catkin works.

Target properties for python module

What properties can I set for a target added with python_add_module in CMake.
$ cmake --version
cmake version 3.14.5
The python_add_module command actually calls add_library() with the STATIC or MODULE clause, depending on your configuration. See the CMake source here. So you can set any of these target properties for targets create via python_add_module.

Platform independent way to find path to libpython (e.g., for use in cmake)

Is there any platform independent way to get the path to a python installation's libpython, for use as a cmake argument? sysconfig.get_config_var gives some pieces but there's no consistent way I can get this working.
On OSX:
No variable contains the actual basename of the library (libpython2.7.dylib)
sysconfig.get_config_var('LIBDIR') returns the directory libpython2.7.dylib is in (/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib)
edit: There seems to be a bit of a discrepancy in when sysconfig is reporting a symlink and when it's reporting a real path. LIBDIR does in fact contain libpython.2.7.dylib, but what I just noticed is that this is a symlink to /usr/local/Cellar/python/2.7.13_1/Frameworks/Python.framework/Versions/2.7/Python.
INSTSONAME points to Python.framework/Versions/2.7/Python, the basename of that path, but no variable I can find points to the parent part of that path.
On Ubuntu:
sysconfig.get_config_var('INSTSONAME') gives me the name of the library (libpython2.7.so.1.0).
No variable contains the directory it's in (/usr/lib/x86_64-linux-gnu/).
LIBDIR returns only /usr/lib
CMake python modules: FindPythonLibs and FindPythonInterp.
If those don't work for you just set the next vars when calling cmake -DPYTHON_EXECUTABLE:FILEPATH, -DPYTHON_LIBRARY:FILEPATH and -DPYTHON_INCLUDE_DIR:FILEPAT, for more info look here.
Example:
cmake .. -G "Sublime Text 2 - Ninja"
-DCMAKE_BUILD_TYPE=Release
-DPYTHON_EXECUTABLE:FILEPATH=d:\virtualenvs\python362_32
-DPYTHON_LIBRARY:FILEPATH=d:\virtualenvs\python362_32\libs\python36.lib
-DPYTHON_INCLUDE_DIR:FILEPAT=d:\virtualenvs\python362_32\include

CMake Error: The following variables are used in this project, but they are set to NOTFOUND. PYTHON_LIBRARIES (ADVANCED)

I'm trying to install this software http://www.openstructure.org/docs/1.4/install/ and I get this error:
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
PYTHON_LIBRARIES (ADVANCED)
linked by target "_ost_conop" in directory /opt/ost/modules/conop/pymod
linked by target "_ost_gfx" in directory /opt/ost/modules/gfx/pymod
linked by target "_ost_img" in directory /opt/ost/modules/img/base/pymod
linked by target "_ost_img_alg" in directory /opt/ost/modules/img/alg/pymod
linked by target "ost_gui" in directory /opt/ost/modules/gui/src
linked by target "_ost_gui" in directory /opt/ost/modules/gui/pymod
linked by target "_ost_io" in directory /opt/ost/modules/io/pymod
linked by target "_ost_info" in directory /opt/ost/modules/info/pymod
linked by target "_ost_seq" in directory /opt/ost/modules/seq/base/pymod
linked by target "_ost_seq_alg" in directory /opt/ost/modules/seq/alg/pymod
linked by target "_ost_mol" in directory /opt/ost/modules/mol/base/pymod
linked by target "_ost_mol_alg" in directory /opt/ost/modules/mol/alg/pymod
linked by target "_ost_geom" in directory /opt/ost/modules/geom/pymod
linked by target "_ost_base" in directory /opt/ost/modules/base/pymod
-- Configuring incomplete, errors occurred!
See also "/opt/ost/CMakeFiles/CMakeOutput.log".
See also "/opt/ost/CMakeFiles/CMakeError.log".
I'm guessing I have to pass the path to PYTHON_LIBRARIES to cmake but I have no idea what. I have the correct python installed and all other dependencies.
First I took this advice https://askubuntu.com/questions/479260/cmake-can-not-find-pythonlibs and installed the latest cmake (3.4.1) from source. This did not solve the problem and I got the same error. However I did solve it using cmake 3.4, not sure if it made a difference though.
I had to run cmake explicitly showing it PYTHON_LIBRARIES suggested from that same thread.
cmake . -DPYTHON_LIBRARIES=/usr/lib/python2.7/config/libpython2.7.so
It was not simply enough to use
export PYTHON_LIBRARIES=/usr/lib/python2.7/config/libpython2.7.so
and then cmake ..

Compile mod_wsgi with non-default Apache Webserver?

I am trying to install mod_wsgi for a updated version of Apache.
I currently have Apache 2.4 installed via /opt/rh/httpd24/root/etc/httpd.
I am wanting to compile with it using 2.4 not 2.2. Any help on the syntax here? I can't find any reference to that specific argument.
[root#bmograba mod_wsgi-4.4.13]# ./configure -help
`configure' configures this package to adapt to many kinds of systems.
Usage: ./configure [OPTION]... [VAR=VALUE]...
To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE. See below for descriptions of some of the useful variables.
Defaults for the options are specified in brackets.
Configuration:
-h, --help display this help and exit
--help=short display options specific to this package
--help=recursive display the short help of all the included packages
-V, --version display version information and exit
-q, --quiet, --silent do not print `checking ...' messages
--cache-file=FILE cache test results in FILE [disabled]
-C, --config-cache alias for `--cache-file=config.cache'
-n, --no-create do not create output files
--srcdir=DIR find the sources in DIR [configure dir or `..']
Installation directories:
--prefix=PREFIX install architecture-independent files in PREFIX
[/usr/local]
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
[PREFIX]
By default, `make install' will install all the files in
`/usr/local/bin', `/usr/local/lib' etc. You can specify
an installation prefix other than `/usr/local' using `--prefix',
for instance `--prefix=$HOME'.
For better control, use the options below.
Fine tuning of the installation directories:
--bindir=DIR user executables [EPREFIX/bin]
--sbindir=DIR system admin executables [EPREFIX/sbin]
--libexecdir=DIR program executables [EPREFIX/libexec]
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
--datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
--datadir=DIR read-only architecture-independent data [DATAROOTDIR]
--infodir=DIR info documentation [DATAROOTDIR/info]
--localedir=DIR locale-dependent data [DATAROOTDIR/locale]
--mandir=DIR man documentation [DATAROOTDIR/man]
--docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE]
--htmldir=DIR html documentation [DOCDIR]
--dvidir=DIR dvi documentation [DOCDIR]
--pdfdir=DIR pdf documentation [DOCDIR]
--psdir=DIR ps documentation [DOCDIR]
Optional Features:
--disable-option-checking ignore unrecognized --enable/--with options
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-framework enable mod_wsgi framework link
--disable-embedded disable mod_wsgi embedded mode
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-apxs=NAME name of the apxs executable [[apxs]]
--with-python=NAME name of the python executable [[python]]
Some influential environment variables:
CC C compiler command
CFLAGS C compiler flags
LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
nonstandard directory <lib dir>
LIBS libraries to pass to the linker, e.g. -l<library>
CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
you have headers in a nonstandard directory <include dir>
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
Report bugs to the package provider.
Compiled plane with no arguments:
[root#bmograba mod_wsgi-4.4.13]# ./configure
checking for apxs2... no
checking for apxs... /usr/sbin/apxs
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for prctl... yes
checking Apache version... 2.2.15
checking for python... /usr/bin/python
configure: creating ./config.status
config.status: creating Makefile
Just to see what package output would be looking for:
[root#bmograba mod_wsgi-4.4.13]# ./configure --with-PACKAGE
configure: WARNING: you should use --build, --host, --target
configure: WARNING: unrecognized options: --with-PACKAGE
checking for apxs2... no
checking for apxs... /usr/sbin/apxs
checking for httpd-gcc... no
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for prctl... yes
checking Apache version... 2.2.15
checking for python... /usr/bin/python
configure: creating ./config.status
config.status: creating Makefile
configure: WARNING: unrecognized options: --with-PACKAGE
When they say, --with-PACKAGE, PACKAGE is just a placeholder for a package name. You aren't supposed to literally put --with-PACKAGE.
Find where the 'apxs' script is inside of the alternate Apache installation. Then run:
./configuure --with-apxs /opt/rh/httpd24/bin/apxs
where that argument is the location of that 'apxs' script.
https://code.google.com/p/modwsgi/wiki/QuickInstallationGuide#Configuring_The_Source_Code

Categories

Resources