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

catkin_make: No module named 'catkin_pkg'

asked 2019-12-21 16:32:35 -0600

shashi gravatar image

updated 2019-12-22 06:22:54 -0600

gvdhoorn gravatar image

I am getting the following error and is unable to remove the same.

#### Running command: "make cmake_check_build_system" in "/home/csio/catkin_ws/build"
####
-- Using CATKIN_DEVEL_PREFIX: /home/csio/catkin_ws/devel
-- Using CMAKE_PREFIX_PATH: /opt/ros/melodic
-- This workspace overlays: /opt/ros/melodic
-- Found PythonInterp: /usr/bin/python3 (found suitable version "3.6.8", minimum required is "2") 
-- Using PYTHON_EXECUTABLE: /usr/bin/python3
-- Using Debian Python package layout
-- Using empy: /usr/bin/empy
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/csio/catkin_ws/build/test_results
-- Found gtest sources under '/usr/src/googletest': gtests will be built
-- Found gmock sources under '/usr/src/googletest': gmock will be built
--Found PythonInterp: /usr/bin/python3 (found version "3.6.8") 
-- Using Python nosetests: /usr/bin/nosetests-2.7
ImportError: "from catkin_pkg.package import parse_package" failed: No module named 'catkin_pkg'
Make sure that you have installed "catkin_pkg", it is up to date and on the PYTHONPATH.
CMake Error at /opt/ros/melodic/share/catkin/cmake/safe_execute_process.cmake:11 (message):
  execute_process(/usr/bin/python3
  "/opt/ros/melodic/share/catkin/cmake/parse_package_xml.py"
  "/opt/ros/melodic/share/catkin/cmake/../package.xml"
  "/home/csio/catkin_ws/build/catkin/catkin_generated/version/package.cmake")
  returned error code 1
Call Stack (most recent call first):
  /opt/ros/melodic/share/catkin/cmake/catkin_package_xml.cmake:74 (safe_execute_process)
  /opt/ros/melodic/share/catkin/cmake/all.cmake:168 (_catkin_package_xml)
  /opt/ros/melodic/share/catkin/cmake/catkinConfig.cmake:20 (include)
  CMakeLists.txt:56 (find_package)


-- Configuring incomplete, errors occurred!
See also "/home/csio/catkin_ws/build/CMakeFiles/CMakeOutput.log".
See also "/home/csio/catkin_ws/build/CMakeFiles/CMakeError.log".
Makefile:320: recipe for target 'cmake_check_build_system' failed
make: *** [cmake_check_build_system] Error 1
Invoking "make cmake_check_build_system" failed 
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2019-12-21 23:03:23 -0600

Abhishekpg gravatar image

Install catkin_pkg using below command

sudo apt-get install python-catkin-pkg

You have to verify that the catkin_pkg is installed into python 3 directory. If below command didn't work, try

pip3 install catkin_pkg

Make sure you have installed pip for running above command

edit flag offensive delete link more

Comments

No, please don't suggest people to use pip to install ROS Python dependencies. It's unnecessary and pip packages are not automatically updated as you circumvent the system's package manager.

There is one exception to this and that would be to install those packages for Python interpreters other than the system default.

But in that case please always mention the downsides, as it has plenty.

gvdhoorn gravatar image gvdhoorn  ( 2019-12-22 06:15:46 -0600 )edit

Ok understood. Can you please tell how to change the python interpreter.

Abhishekpg gravatar image Abhishekpg  ( 2019-12-22 07:07:28 -0600 )edit

On running the above suggestion, I received this error:

Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/usr/local/lib/python3.6/dist-packages/catkin_pkg' Consider using the --user option or check the permissions.

shashi gravatar image shashi  ( 2019-12-22 22:36:55 -0600 )edit

Try adding --user at the end of the command

Abhishekpg gravatar image Abhishekpg  ( 2019-12-22 23:13:48 -0600 )edit
2

answered 2019-12-22 06:20:41 -0600

gvdhoorn gravatar image

updated 2019-12-22 06:22:26 -0600

This is most likely your problem:

-- Found PythonInterp: /usr/bin/python3 (found suitable version "3.6.8", minimum required is "2") 
-- Using PYTHON_EXECUTABLE: /usr/bin/python3
...
-- Found PythonInterp: /usr/bin/python3 (found version "3.6.8")

Note how it says: Python 3 is found and used.

The Debian packages provided by the ROS buildfarm for Melodic are only installed for the default system provided Python interpreter. On Ubuntu Bionic (which you are most likely running, seeing as you tagged with melodic) that would still be Python 2.

As the Python 3 interpreter is found instead, none of the required Python packages are installed for it and this results in the error you show.

You'll either have to install catkin_pkg (and a few others) for the Python 3 interpreter (using the pip3 command shown by @Abhishekpg ), or make sure Catkin uses the Python 2 interpreter.

My recommendation would be the latter, as the rest of Melodic will also have been built against Python 2. Not Python 3.

The next release of ROS 1 (Noetic) will support Python 3.

edit flag offensive delete link more

Comments

How do I make sure that Catkin uses Python 2 interpreter? Is there a workaround?

shashi gravatar image shashi  ( 2019-12-22 22:36:42 -0600 )edit

In my case, I had to install sudo apt install python-pip and sudo apt install python3-pipand it automatically chose the right pip (Python 2.7 or 3.6) during installation. Perhaps you can even leave out python3-pip installation, but it does not harm at least. See https://stackoverflow.com/questions/6....

everything gravatar image everything  ( 2020-12-28 09:50:55 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2019-12-21 16:32:35 -0600

Seen: 7,921 times

Last updated: Dec 22 '19