ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Python.h: No such file or directory

asked 2020-06-19 07:16:50 -0500

azerila gravatar image

I am building a package where my catkin config cmage args are:

Additional CMake Args:       -DPYTHON_EXECUTABLE=/usr/bin/python3 -DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.6m.so -DPYTHON_INCLUDE_DIR=/usr/include/python3.6m

and in the CMakeLists.txt also I have:

include_directories(include
                   ${PYTHON_INCLUDE_DIRS}
                    ...
                    )

but still get the following error during build:

fatal error: Python.h: No such file or directory
 #include <Python.h>

anyone knows a solution for this?

edit retag flag offensive close merge delete

Comments

If I am not wrong. ROS melodic uses python2.7, not Python 3

You could try ROS Noetic.

Solrac3589 gravatar image Solrac3589  ( 2020-06-19 07:52:17 -0500 )edit

@Solrac3589 yea by default it is python2.7 but with cmake arguments it is also possible in general to use python3 in it. at the moment it would take very long to make my application compatible wiht Noetic, and it seems it shouldn't be hard to make it find that python.h file, it's strange...

azerila gravatar image azerila  ( 2020-06-19 08:01:35 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-07-13 02:39:20 -0500

Most of the time these are dependency-issues. Python.h is used by GNU Compiler Collection (gcc) to build applications. You need to install a package called python-dev for building Python modules, extending the Python interpreter or embedding Python in applications. You encounter "Python.h: No such file or directory" error while trying to build a shared library using the file extension of another language ( e.g. 'C' ). If you are trying to build a shared library using the file extension of another language, you need to install the correct development version of Python.

Reason for this error:

  • You haven't properly installed the header files and static libraries for python dev.
  • Also, sometimes include files might not be default in the include path.

How to solve this error:

  • Install the missing files and
  • libraries. Include Path and Library.
  • Finally, Compile it.
edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2020-06-19 07:16:50 -0500

Seen: 1,674 times

Last updated: Jun 19 '20