Robotics StackExchange | Archived questions

catkin_make: no module named catkin_pkg

I don't understand catkin_make. I want to install ROS and move to robot.

Install finished. How to install

http://wiki.ros.org/kinetic/Installation/Ubuntu

I referred to it. http://wiki.ros.org/ROS/Tutorials/InstallingandConfiguringROSEnvironment

3.Create a ROS Workspace

Fail at the beginning of Chapter 3 create and build a catkin workspace:

Please,show me how to good idea

environment Ubuntu16.0.4 windows10 Hyper-V

error

~/catkin_ws$ catkin_make
Base path: /home/yuma/catkin_ws
Source space: /home/yuma/catkin_ws/src
Build space: /home/yuma/catkin_ws/build
Devel space: /home/yuma/catkin_ws/devel
Install space: /home/yuma/catkin_ws/install
####
#### Running command: "cmake /home/yuma/catkin_ws/src -DCATKIN_DEVEL_PREFIX=/home/yuma/catkin_ws/devel -DCMAKE_INSTALL_PREFIX=/home/yuma/catkin_ws/install -G Unix Makefiles" in "/home/yuma/catkin_ws/build"
####
-- Using CATKIN_DEVEL_PREFIX: /home/yuma/catkin_ws/devel
-- Using CMAKE_PREFIX_PATH: /opt/ros/kinetic
-- This workspace overlays: /opt/ros/kinetic
-- 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/yuma/catkin_ws/build/test_results
-- Found gmock sources under '/usr/src/gmock': gmock will be built
-- Found gtest sources under '/usr/src/gmock': gtests will be built
-- 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/kinetic/share/catkin/cmake/safe_execute_process.cmake:11 (message):
  execute_process(/usr/bin/python3
  "/opt/ros/kinetic/share/catkin/cmake/parse_package_xml.py"
  "/opt/ros/kinetic/share/catkin/cmake/../package.xml"
  "/home/yuma/catkin_ws/build/catkin/catkin_generated/version/package.cmake")
  returned error code 1
Call Stack (most recent call first):
  /opt/ros/kinetic/share/catkin/cmake/catkin_package_xml.cmake:74 (safe_execute_process)
  /opt/ros/kinetic/share/catkin/cmake/all.cmake:167 (_catkin_package_xml)
  /opt/ros/kinetic/share/catkin/cmake/catkinConfig.cmake:20 (include)
  CMakeLists.txt:56 (find_package)


-- Configuring incomplete, errors occurred!
See also "/home/yuma/catkin_ws/build/CMakeFiles/CMakeOutput.log".
See also "/home/yuma/catkin_ws/build/CMakeFiles/CMakeError.log".
Invoking "cmake" failed

Asked by YUMA on 2019-11-08 02:54:47 UTC

Comments

Answers

The problem is most likely this:

-- Using PYTHON_EXECUTABLE: /usr/bin/python3

ROS Python packages (or really: Debian/Ubuntu Python packages) are only installed for the default system-provided Python interpreter, which would be Python 2 on Ubuntu Xenial.

As Catkin (or really: CMake) detects Python 3 as the default interpreter, and catkin_pkg is not installed for that version, you get the error message you show.

You'll need to either install catkin_pkg for Python 3 (sudo apt install python3-catkin-pkg) or make the default system-interpreter Python 2 again or override which version of Python Catkin/CMake uses by setting -DPYTHON_VERSION=3.5 when invoking catkin_make.

If you require further information or assistance, I'd recommend searching this forum for Python 3 related problems with Catkin (or any of the ROS 1 packages) as there have been quite a nr of posts about that (use Google: no module named site:answers.ros.org).

Asked by gvdhoorn on 2019-11-08 04:49:32 UTC

Comments

Thank you,answered !! Does that mean writing the override code before writing the error code?

Asked by YUMA on 2019-11-10 19:26:32 UTC

Does that mean writing the override code before writing the error code?

I don't know what you mean by that.

Asked by gvdhoorn on 2019-11-11 02:24:10 UTC

@gvdhoom could you expand or point to documentation that details how the "default interpreter" is defined? Does this mean simply what "python" resolves to in your terminal?

Asked by topherbuckley on 2021-05-10 02:42:29 UTC

The default interpreter would be whatever your OS vendor and/or Linux/Ubuntu distribution has configured as the default version.

Linux distributions typically list the versions of important parts of the OS in the release notes, or on their support forum. You'll have to try and find that for whichever OS you're using.

Does this mean simply what "python" resolves to in your terminal?

no, not necessarily.

On Ubuntu for instance it's possible to use update-alternatives to change whatever the default is. So relying on the output of which (which I believe you're referring to) is not going to be robust.

(note: do not try to use update-alternatives to switch from Python 2 to Python 3, or the other way around. That will most likely not work. Overriding the default Python interpreter on Debian/Ubuntu with an Anaconda install will most likely also not work)

Asked by gvdhoorn on 2021-05-10 03:13:31 UTC