Robotics StackExchange | Archived questions

cannot catkin build

I have been trying to catkin build. I get error

ImportError: "from catkin_pkg.package import parse_package" failed: No module named catkin_pkg.package
Make sure that you have installed "catkin_pkg", it is up to date and on the PYTHONPATH.

I have tried figuring out how to add to PYTHONPATH but to no avail.I'm probably doing something wrong. I want to add to python3 path. I make sure catkinpkg is in python3.6 directory. I `locate catkinpkg` and get :

/usr/lib/python2.7/dist-packages/catkin_pkg
/usr/lib/python2.7/dist-packages/catkin_pkg-0.4.23.egg-info
/usr/lib/python2.7/dist-packages/catkin_pkg_modules-0.4.23.egg-info
/usr/local/MATLAB/R2020b/sys/ros1/share/python/catkin_pkg-0.4.13.tar.gz
/usr/local/MATLAB/R2020b/sys/ros2/share/python/catkin_pkg-0.4.12-py3-none-any.whl
/usr/local/lib/python3.6/dist-packages/catkin_pkg
/usr/local/lib/python3.6/dist-packages/catkin_pkg-0.4.23.dist-info
/usr/local/lib/python3.6/dist-packages/catkin_pkg/__init__.py
/usr/local/lib/python3.6/dist-packages/catkin_pkg/__pycache__
/usr/local/lib/python3.6/dist-packages/catkin_pkg/changelog.py
/usr/local/lib/python3.6/dist-packages/catkin_pkg/changelog_generator.py
/usr/local/lib/python3.6/dist-packages/catkin_pkg/changelog_generator_vcs.py
/usr/local/lib/python3.6/dist-packages/catkin_pkg/cli
/usr/local/lib/python3.6/dist-packages/catkin_pkg/cmake.py
/usr/local/lib/python3.6/dist-packages/catkin_pkg/condition.py
/usr/local/lib/python3.6/dist-packages/catkin_pkg/group_dependency.py
/usr/local/lib/python3.6/dist-packages/catkin_pkg/group_membership.py
/usr/local/lib/python3.6/dist-packages/catkin_pkg/metapackage.py
/usr/local/lib/python3.6/dist-packages/catkin_pkg/package.py
/usr/local/lib/python3.6/dist-packages/catkin_pkg/package_templates.py
/usr/local/lib/python3.6/dist-packages/catkin_pkg/package_version.py
/usr/local/lib/python3.6/dist-packages/catkin_pkg/packages.py
/usr/local/lib/python3.6/dist-packages/catkin_pkg/python_setup.py
/usr/local/lib/python3.6/dist-packages/catkin_pkg/rospack.py
/usr/local/lib/python3.6/dist-packages/catkin_pkg/templates
/usr/local/lib/python3.6/dist-packages/catkin_pkg/terminal_color.py
/usr/local/lib/python3.6/dist-packages/catkin_pkg/tool_detection.py
/usr/local/lib/python3.6/dist-packages/catkin_pkg/topological_order.py
/usr/local/lib/python3.6/dist-packages/catkin_pkg/workspace_vcs.py
/usr/local/lib/python3.6/dist-packages/catkin_pkg/workspaces.py
/usr/local/lib/python3.6/dist-packages/catkin_pkg/__pycache__/__init__.cpython-36.pyc
/usr/local/lib/python3.6/dist-packages/catkin_pkg/__pycache__/changelog.cpython-36.pyc
/usr/local/lib/python3.6/dist-packages/catkin_pkg/__pycache__/changelog_generator.cpython-36.pyc
/usr/local/lib/python3.6/dist-packages/catkin_pkg/__pycache__/changelog_generator_vcs.cpython-36.pyc
/usr/local/lib/python3.6/dist-packages/catkin_pkg/__pycache__/cmake.cpython-36.pyc
/usr/local/lib/python3.6/dist-packages/catkin_pkg/__pycache__/condition.cpython-36.pyc
/usr/local/lib/python3.6/dist-packages/catkin_pkg/__pycache__/group_dependency.cpython-36.pyc
/usr/local/lib/python3.6/dist-packages/catkin_pkg/__pycache__/group_membership.cpython-36.pyc
/usr/local/lib/python3.6/dist-packages/catkin_pkg/__pycache__/metapackage.cpython-36.pyc
/usr/local/lib/python3.6/dist-packages/catkin_pkg/__pycache__/package.cpython-36.pyc
/usr/local/lib/python3.6/dist-packages/catkin_pkg/__pycache__/package_templates.cpython-36.pyc
/usr/local/lib/python3.6/dist-packages/catkin_pkg/__pycache__/package_version.cpython-36.pyc
/usr/local/lib/python3.6/dist-packages/catkin_pkg/__pycache__/packages.cpython-36.pyc
/usr/local/lib/python3.6/dist-packages/catkin_pkg/__pycache__/python_setup.cpython-36.pyc
/usr/local/lib/python3.6/dist-packages/catkin_pkg/__pycache__/rospack.cpython-36.pyc
/usr/local/lib/python3.6/dist-packages/catkin_pkg/__pycache__/terminal_color.cpython-36.pyc
/usr/local/lib/python3.6/dist-packages/catkin_pkg/__pycache__/tool_detection.cpython-36.pyc
/usr/local/lib/python3.6/dist-packages/catkin_pkg/__pycache__/topological_order.cpython-36.pyc
/usr/local/lib/python3.6/dist-packages/catkin_pkg/__pycache__/workspace_vcs.cpython-36.pyc
/usr/local/lib/python3.6/dist-packages/catkin_pkg/__pycache__/workspaces.cpython-36.pyc
/usr/local/lib/python3.6/dist-packages/catkin_pkg/cli/__init__.py
/usr/local/lib/python3.6/dist-packages/catkin_pkg/cli/__pycache__
/usr/local/lib/python3.6/dist-packages/catkin_pkg/cli/create_pkg.py
/usr/local/lib/python3.6/dist-packages/catkin_pkg/cli/find_pkg.py
/usr/local/lib/python3.6/dist-packages/catkin_pkg/cli/generate_changelog.py
/usr/local/lib/python3.6/dist-packages/catkin_pkg/cli/package_version.py
/usr/local/lib/python3.6/dist-packages/catkin_pkg/cli/prepare_release.py
/usr/local/lib/python3.6/dist-packages/catkin_pkg/cli/tag_changelog.py
/usr/local/lib/python3.6/dist-packages/catkin_pkg/cli/test_changelog.py
/usr/local/lib/python3.6/dist-packages/catkin_pkg/cli/__pycache__/__init__.cpython-36.pyc
/usr/local/lib/python3.6/dist-packages/catkin_pkg/cli/__pycache__/create_pkg.cpython-36.pyc
/usr/local/lib/python3.6/dist-packages/catkin_pkg/cli/__pycache__/find_pkg.cpython-36.pyc
/usr/local/lib/python3.6/dist-packages/catkin_pkg/cli/__pycache__/generate_changelog.cpython-36.pyc
/usr/local/lib/python3.6/dist-packages/catkin_pkg/cli/__pycache__/package_version.cpython-36.pyc
/usr/local/lib/python3.6/dist-packages/catkin_pkg/cli/__pycache__/prepare_release.cpython-36.pyc
/usr/local/lib/python3.6/dist-packages/catkin_pkg/cli/__pycache__/tag_changelog.cpython-36.pyc
/usr/local/lib/python3.6/dist-packages/catkin_pkg/cli/__pycache__/test_changelog.cpython-36.pyc
/usr/local/lib/python3.6/dist-packages/catkin_pkg/templates/CMakeLists.txt.in
/usr/local/lib/python3.6/dist-packages/catkin_pkg/templates/metapackage.cmake.in
/usr/local/lib/python3.6/dist-packages/catkin_pkg/templates/package.xml.in
/usr/local/lib/python3.6/dist-packages/catkin_pkg-0.4.23.dist-info/INSTALLER
/usr/local/lib/python3.6/dist-packages/catkin_pkg-0.4.23.dist-info/LICENSE
/usr/local/lib/python3.6/dist-packages/catkin_pkg-0.4.23.dist-info/METADATA
/usr/local/lib/python3.6/dist-packages/catkin_pkg-0.4.23.dist-info/RECORD
/usr/local/lib/python3.6/dist-packages/catkin_pkg-0.4.23.dist-info/WHEEL
/usr/local/lib/python3.6/dist-packages/catkin_pkg-0.4.23.dist-info/entry_points.txt
/usr/local/lib/python3.6/dist-packages/catkin_pkg-0.4.23.dist-info/top_level.txt

So I know it's there, I just need to add to path This is the bottom part of my bashrc right now:

source ~/server_prac/devel/setup.bash
export TURTLEBOT3_MODEL=burger

#export ROS_MASTER_URI=http://10.130.220.94:11311
#export ROS_HOSTNAME=10.130.220.94
export ROS_MASTER_URI=http://10.21.112.133:11311
export ROS_HOSTNAME=10.21.112.133                                                                   

export TURTLEBOT3_MODEL=burger
export DINGO_OMNI=1

export PATH=`pwd`/cmake-3.23/bin:$PATH

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

What am I doing wrong?

Asked by distro on 2022-04-19 02:39:15 UTC

Comments

A silly question but did you installed python catkin tools? If not you can do it using this command, sudo apt install ros-$ROS_DISTRO-catkin python3-catkin-tools. (Edit) Just checked you are on ros-melodic. For python2 sudo apt install ros-$ROS_DISTRO-catkin python-catkin-tools

Asked by aarsh_t on 2022-04-19 03:00:44 UTC

Answers

Did you try with pip install catkin_pkg/pip3 install catkin_pkg?

EDIT:

Check @aarsh_t comment too

Asked by ljaniec on 2022-04-19 03:00:56 UTC

Comments

@aarsh_t I already have catkin_pkg I need to set my catkin build to the path where the catkin_pkg is. I need help with that.

Asked by distro on 2022-04-19 19:42:49 UTC

you can update your PYTHONPATH using export PYTHONPATH=$PYTHONPATH:/usr/lib/python2.7/dist-packages:/usr/local/lib/python3.6/dist-packages

For permanent solution add this to the end of your ~/.bashrc

Asked by aarsh_t on 2022-04-20 03:04:57 UTC