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

ImportError: No module named catkin.environment_cache

asked 2020-01-27 14:34:56 -0600

broomstick gravatar image

updated 2021-04-21 00:37:41 -0600

lucasw gravatar image

I'm building on a MacBook Pro running Catalina 10.15.2.

I'm following the OSX build instructions here:

I am at step 2.5.2 (Building the Catkin Workspace).

I provide the command: ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release -DCMAKE_MACOSX_RPATH=ON -DCMAKE_INSTALL_RPATH=$HOME/ros_catkin_ws/install_isolated/lib

17 packages (of 54) install just fine, then I get the following error when building rosboost_cfg:

Traceback (most recent call last):
  File "[$HOME]/melodic_catkin_ws/build_isolated/rosboost_cfg/catkin_generated/", line 20, in <module>
    from catkin.environment_cache import generate_environment_script
ImportError: No module named catkin.environment_cache
CMake Error at [$HOME]/melodic_catkin_ws/install_isolated/share/catkin/cmake/safe_execute_process.cmake:11 (message):
  returned error code 1
Call Stack (most recent call first):
  [$HOME]/melodic_catkin_ws/install_isolated/share/catkin/cmake/all.cmake:208 (safe_execute_process)
  [$HOME]/melodic_catkin_ws/install_isolated/share/catkin/cmake/catkinConfig.cmake:20 (include)
  CMakeLists.txt:3 (find_package)

I have reviewed @mikepurvis work from a few years ago for catkin_tools( and the associated PR (

I'm having the problem with catkin_make_isolated, however, and am unsure how I could apply the changes from catkin_tools.

I think I'm having the same mutex problems as those previously reported:

If I run catkin_make_isolated with --only-pkg-with-deps=rosboost_cfg, it builds catkin and rosboost_cfg without any problems.

I then attempt to run catkin_make_isolated with --ignore-pkg=rosboost_cfg and it eventually chokes with ImportError: No module named catkin.environment_cache on rosbuild.

I attempt the same process on rosbuild (i.e., --only-pkg-with-deps=rosbuild), but there are enough dependencies there that I eventually get ImportError: No module named catkin.environment_cache while processing one of the dependencies.

edit retag flag offensive close merge delete


What do the following commands output: python --version and python -c "import catkin_pkg; print(catkin_pkg.__version__)"?

Dirk Thomas gravatar image Dirk Thomas  ( 2020-01-27 14:43:14 -0600 )edit

python --version is Python 3.7.5. python -c "import catkin_pkg; print(catkin_pkg.__version__)" is 0.4.16.

My Python symlink should be to 2.7. I changed it (now reporting Python 2.7.16). I reran the rosdep commands and then rebuild the workspace. It worked.

I still had to brew install lz4.

I can convert this into an answer, unless you want to flesh it out with some detail about why I got the error consistently for certain packages with Python 3, and why it was partially fixed by only building the offending package and its dependencies. It might not help anyone, but I am curious...

Thanks again for the help.

broomstick gravatar image broomstick  ( 2020-01-27 15:13:28 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2020-01-27 15:31:33 -0600

Dirk Thomas gravatar image

Either the Python package catkin_pkg is not new enough or can't be found.

In this case you are using Python 3 but only have the package installed for Python 2. Using Python 2 made it work.

edit flag offensive delete link more

Question Tools



Asked: 2020-01-27 14:34:56 -0600

Seen: 6,098 times

Last updated: Apr 21 '21