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

7

8

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

Gratitude answered 26/3, 2017 at 2:33 Comment(0)
A
14

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

Acton answered 31/3, 2017 at 15:57 Comment(0)
L
4

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.

Lothians answered 9/9, 2017 at 20:19 Comment(2)
when will ros play nice with conda this is @#$ ridiculous!Doralin
@neuronet I share your pain :)Lothians
M
3

The Error Output:

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.

As mentioned above you need have "catkin_pkg" in PYTHONPATH. The easiest way if you ask me is:

$ pip install catkin_pkg

Moderato answered 31/5, 2018 at 11:20 Comment(0)
S
2

try this : pip install -U rosdep rosinstall_generator wstool rosinstall six vcstools

if pip shows any errror, switch to root and install pip and then try

Sherri answered 5/6, 2018 at 5:3 Comment(0)
C
0

Actually when you want to use Anaconda and ROS simultaneously then generally this error comes. So firstly go in .bashrc file and comment the path of anaconda.

Export PATH="/home/gaurav/anaconda3/bin:$PATH".

After commenting go in catkin_ws folder and delete the existing folder within the folder and make new src folder. Then follow three steps:

1 - $ mkdir src

2 - $ catkin_init_workspace src

3 - $ catkin_make

It works for me.

Cadaverine answered 19/8, 2019 at 6:23 Comment(0)
T
0

This means you havent sourced ROS into your environment.

Add this line to the last line of your .bashrc file

source /opt/ros/kinetic/setup.bash

Save the .bashrc file, close the current terminal and start your process in a new terminal.

Territorial answered 1/5, 2020 at 4:29 Comment(0)
O
0

for me, it fixed by

sudo apt-get remove python3-catkin-tools
sudo apt-get install python-catkin-tools
Oatcake answered 23/12, 2021 at 11:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.