Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why this error when I try to create workspaces in ROS?

Whenever I try to create a workspace:

~/catkin_ws$ catkin_make

It shows like this:

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(/home/usuario/miniconda3/bin/python
  "/opt/ros/kinetic/share/catkin/cmake/parse_package_xml.py"
  "/opt/ros/kinetic/share/catkin/cmake/../package.xml"
  "/home/usuario/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:63 (safe_execute_process)
  /opt/ros/kinetic/share/catkin/cmake/all.cmake:151 (_catkin_package_xml)
  /opt/ros/kinetic/share/catkin/cmake/catkinConfig.cmake:20 (include)
  CMakeLists.txt:52 (find_package)


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

It seems like there is a problem with catkin_pkg but I dont find the solution

like image 553
rachuism Avatar asked Mar 26 '17 02:03

rachuism


People also ask

Can you have multiple workspaces in ROS?

In this tutorial I'll show you how to create multiple catkin workspaces with ROS. Sometimes you want to create different projects for different robots. The easiest way to manage that is to create several catkin workspaces, one for each robot project.

What is a workspace in ROS?

A workspace is a set of directories (or folders) where you store related pieces of ROS code. The official name for workspaces in ROS is catkin workspaces.


2 Answers

I just installed ROS on Ubuntu 16.04, had the same issue, and fixed it. The location for catkin_pkg is likely not on your PYTHONPATH and needs to be added.

From the error output:

Make sure that you have installed "catkin_pkg", it is up to date and on the PYTHONPATH.

Try locating catkin_pkg and check your PYTHONPATH. catkin_pkg wasn't on my PYTHONPATH (likely due to other program installs), so I added it and ran catkin_make again, this time successfully.

~/catkin_ws$ locate catkin_pkg
/usr/lib/python2.7/dist-packages/catkin_pkg

~/catkin_ws$ echo $PYTHONPATH
/opt/ros/kinetic/lib/python2.7/dist-packages

To append the catkin_pkg dir to PYTHONPATH (for this session):

~/catkin_ws$ export PYTHONPATH=$PYTHONPATH:/usr/lib/python2.7/dist-packages

For permanency I appended the catkin_pkg dir to PYTHONPATH in my .bashrc (you might want to backup your .bashrc file first, e.g. cp -p ~/.bashrc ~/.bashrc-ros-catkin.bak).

To do this, edit your ~/.bashrc file (you might need to use sudo to edit this file) and add the following two lines to the end of the file:

# manually added for ROS catkin_make workspace setup
export PYTHONPATH=$PYTHONPATH:/usr/lib/python2.7/dist-packages

Save the file and run source to update your session:

~/catkin_ws$ source ~/.bashrc

Check your PYTHONPATH again:

~/catkin_ws$ echo $PYTHONPATH
/opt/ros/kinetic/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages

Obviously the location of your catkin_pkg files might be different to mine, so use that path instead when appending to $PYTHONPATH above.

Now try running catkin_make again. If you get the same error, paste the output of your catkin_pkg location and PYTHONPATH here.

Cheers, sb

like image 195
stephenb Avatar answered Oct 24 '22 22:10

stephenb


Are you using Anaconda environment? This issue is quite common with Anaconda's Python installation.

Try: python --version

If you see Anaconda in the output, go to your bashrc file with vi ~/.bashrc and then comment the line where anaconda is added to path. It would be something like,

export PATH="username/anaconda2/bin:$PATH"

After that source your bashrc with source ~/.bashrc, open a new terminal and navigate to your catkin workspace. Delete the old build folder and try the catkin_make command again.

Should solve your issue.

like image 37
Vatsal Srivastava Avatar answered Oct 25 '22 00:10

Vatsal Srivastava