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

Ubuntu18 and ROS melodic catkin error: ImportError: No module named terminal_color

asked 2018-06-20 16:35:45 -0500

Jaxxl gravatar image

updated 2022-01-22 16:09:51 -0500

Evgeny gravatar image

I exactly followed the instructions from http://wiki.ros.org/melodic/Installat... .

Then I created a workspace by

cd
mkdior -p catkin_ws/src
cd catkin_ws/src
catkin_init_workspace
cd ..
catkin_make

The I got

Traceback (most recent call last):
  File "/opt/ros/melodic/bin/catkin_make", line 13, in <module>
    from catkin.terminal_color import disable_ANSI_colors, fmt
  File "/opt/ros/melodic/lib/python2.7/dist-packages/catkin/terminal_color.py", line 2, in <module>
    from catkin_pkg.terminal_color import *  # noqa
ImportError: No module named terminal_color

I googled and tried everything I could(except for reinstalling my OS). But the problem is still there.

For example, to give more info:

Run

sudo dpkg -L python-catkin-pkg

and got

/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/python-catkin-pkg
/usr/share/doc/python-catkin-pkg/changelog.Debian.gz
/usr/bin
/usr/bin/catkin_generate_changelog
/usr/bin/catkin_prepare_release
/usr/bin/catkin_tag_changelog
/usr/bin/catkin_create_pkg
/usr/bin/catkin_test_changelog
/usr/bin/catkin_package_version
/usr/bin/catkin_find_pkg
/usr/lib
/usr/lib/python2.7
/usr/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages/catkin_pkg-0.4.3.egg-info
/usr/lib/python2.7/dist-packages/catkin_pkg-0.4.3.egg-info/top_level.txt
/usr/lib/python2.7/dist-packages/catkin_pkg-0.4.3.egg-info/dependency_links.txt
/usr/lib/python2.7/dist-packages/catkin_pkg-0.4.3.egg-info/requires.txt
/usr/lib/python2.7/dist-packages/catkin_pkg-0.4.3.egg-info/SOURCES.txt
/usr/lib/python2.7/dist-packages/catkin_pkg-0.4.3.egg-info/entry_points.txt
/usr/lib/python2.7/dist-packages/catkin_pkg-0.4.3.egg-info/PKG-INFO

And

python -c 'import catkin_pkg; print(catkin_pkg.__file__)'

got

/usr/lib/python2.7/dist-packages/catkin_pkg/__init__.pyc

And

printenv | grep ROS
ROS_ETC_DIR=/opt/ros/melodic/etc/ros
ROS_ROOT=/opt/ros/melodic/share/ros
ROS_MASTER_URI=http://localhost:11311
ROS_VERSION=1
ROS_PYTHON_VERSION=2
ROS_PACKAGE_PATH=/opt/ros/melodic/share
ROSLISP_PACKAGE_DIRECTORIES=
ROS_DISTRO=melodic

Any suggestion? Thanks in advance!

Edit:

dpkg -L python-catkin-pkg-modules
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/python-catkin-pkg-modules
/usr/share/doc/python-catkin-pkg-modules/changelog.Debian.gz
/usr/lib
/usr/lib/python2.7
/usr/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages/catkin_pkg
/usr/lib/python2.7/dist-packages/catkin_pkg/metapackage.py
/usr/lib/python2.7/dist-packages/catkin_pkg/__init__.py
/usr/lib/python2.7/dist-packages/catkin_pkg/group_membership.py
/usr/lib/python2.7/dist-packages/catkin_pkg/changelog_generator.py
/usr/lib/python2.7/dist-packages/catkin_pkg/tool_detection.py
/usr/lib/python2.7/dist-packages/catkin_pkg/topological_order.py
/usr/lib/python2.7/dist-packages/catkin_pkg/packages.py
/usr/lib/python2.7/dist-packages/catkin_pkg/package.py
/usr/lib/python2.7/dist-packages/catkin_pkg/cmake.py
/usr/lib/python2.7/dist-packages/catkin_pkg/package_templates.py
/usr/lib/python2.7/dist-packages/catkin_pkg/package_version.py
/usr/lib/python2.7/dist-packages/catkin_pkg/python_setup.py
/usr/lib/python2.7/dist-packages/catkin_pkg/changelog.py
/usr/lib/python2.7/dist-packages/catkin_pkg/group_dependency.py
/usr/lib/python2.7/dist-packages/catkin_pkg/workspaces.py
/usr/lib/python2.7/dist-packages/catkin_pkg/templates
/usr/lib/python2.7/dist-packages/catkin_pkg/templates/CMakeLists.txt.in
/usr/lib/python2.7/dist-packages/catkin_pkg/templates/metapackage.cmake.in
/usr/lib/python2.7/dist-packages/catkin_pkg/templates/package.xml.in
/usr/lib/python2.7/dist-packages/catkin_pkg/changelog_generator_vcs.py
/usr/lib/python2.7/dist-packages/catkin_pkg/rospack.py
/usr ...
(more)
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
4

answered 2018-06-20 17:39:50 -0500

Dirk Thomas gravatar image

updated 2019-04-04 16:58:31 -0500

The Python module in question has recently been moved from catkin into catkin_pkg. It is actually in the Debian python-catkin-pkg-modules. Can you please post the output of dpkg -L python-catkin-pkg-modules. Maybe you haven't update that package to the same version as python-catkin-pkg?

Edit: Make sure both packages are up-to-date: sudo apt update && sudo apt install --reinstall python-catkin-pkg python-catkin-pkg-modules

edit flag offensive delete link more

Comments

Thanks for your answer! The version indeed does not match. I fixed the problem by upgrading python-catkin-pkg-modules with sudo pip install --upgrade catkin_pkg_modules.

Jaxxl gravatar image Jaxxl  ( 2018-06-21 15:48:28 -0500 )edit
2

We highly discourage users to install these packages through pip. The problem is that even if you install future versions of the Debian package the pip installed version will be used and likely leading to problem.

Dirk Thomas gravatar image Dirk Thomas  ( 2018-08-08 21:11:52 -0500 )edit
1

"sudo apt update && sudo apt install python-catkin-pkg python-catkin-pkg-modules" says that everything is up to date with ROS kinetic but the problem persists.

inspire gravatar image inspire  ( 2018-08-27 07:42:13 -0500 )edit

okay I found a workaround: https://answers.ros.org/question/3017...

inspire gravatar image inspire  ( 2018-08-27 08:20:06 -0500 )edit

I am having the same problem as this user was, but when I try to run the command you recommend, I get a result saying:

sudo: python-catkin-pkg: command not found

Have any other names been changed since last June?

cwbullivant gravatar image cwbullivant  ( 2019-04-04 16:48:17 -0500 )edit

The right command is: sudo apt install --reinstall python-catkin-pkg python-catkin-pkg-modules

Dirk Thomas gravatar image Dirk Thomas  ( 2019-04-04 16:58:58 -0500 )edit

I've run that command and the packages were reinstalled. However, the error persists.

I ran dpkg -L python-catkin-pkg-modules after reinstalling and got mostly the same output as the above user (with these added lines at the bottom):

/usr/lib/python2.7/dist-packages/catkin_pkg_modules-0.4.11.egg-info
/usr/lib/python2.7/dist-packages/catkin_pkg_modules-0.4.11.egg-info/PKG-INFO
/usr/lib/python2.7/dist-packages/catkin_pkg_modules-0.4.11.egg-info/dependency_links.txt
/usr/lib/python2.7/dist-packages/catkin_pkg_modules-0.4.11.egg-info/requires.txt
/usr/lib/python2.7/dist-packages/catkin_pkg_modules-0.4.11.egg-info/top_level.txt

Even more strangely, typing "from catkin_pkg.terminal_color import *" into the interpreter from the command line works just fine. It's only when this line is invoked from catkin_make that it fails.

cwbullivant gravatar image cwbullivant  ( 2019-04-11 14:46:54 -0500 )edit

I have run above command, but python-catkin-pkg-modules was not found. And python-catkin-pkg had no dependencies. However, the error is occurring. Any ideas?

$ uname -v
#26~18.04.1-Ubuntu SMP Thu Jun 27 07:28:31 UTC 2019
$ sudo apt install python-catkin-pkg-modules
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package python-catkin-pkg-modules
$ apt list | grep python-catkin-pkg

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

python-catkin-pkg/bionic,bionic,now 0.3.9-1 all [installed]
liqsuq gravatar image liqsuq  ( 2019-07-16 21:02:13 -0500 )edit
0

answered 2018-06-21 15:51:41 -0500

Jaxxl gravatar image

updated 2019-04-04 19:27:39 -0500

jayess gravatar image
As Dirk answered, the error is caused by the version mismatch of `python-catkin-pkg-modules` (0.4.1) and `python-catkin-pkg`(0.4.3). This can be fixed by upgrading `python-catkin-pkg-modules`: sudo pip install --upgrade catkin_pkg_modules

Edit: Please first follow the above accepted answer.

edit flag offensive delete link more

Comments

The line you describe doesn't work. The modules package is not available through pip but only through apt.

Dirk Thomas gravatar image Dirk Thomas  ( 2018-06-21 16:03:24 -0500 )edit

@Dirk Thanks for your updates. I remember I upgraded catkin_pkg_modules through pip. Even now I can run pip install --upgrade catkin_pkg_modules without errors: Requirement already up-to-date: catkin_pkg_modules in /usr/lib/python2.7/dist-packages (0.4.3)

Jaxxl gravatar image Jaxxl  ( 2018-06-28 15:59:58 -0500 )edit

pip worked for me just fine.

jamesbellaero gravatar image jamesbellaero  ( 2018-08-08 15:55:34 -0500 )edit
1

We highly discourage users to install these packages through pip. The problem is that even if you install future versions of the Debian package the pip installed version will be used and likely leading to problem.

Dirk Thomas gravatar image Dirk Thomas  ( 2018-08-08 21:12:30 -0500 )edit

the "pip install --upgrade catkin_pkg_modules" command (without sudo) tells me it is already up to date (ROS kinetic here) but I am also stuck with the problem of "no module named terminal_color"...

inspire gravatar image inspire  ( 2018-08-27 07:36:21 -0500 )edit
1

As @Dirk Thomas already writes: do not use pip for this.

gvdhoorn gravatar image gvdhoorn  ( 2018-08-27 07:38:30 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2018-06-20 16:35:45 -0500

Seen: 10,905 times

Last updated: Apr 04 '19