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

catkin python package not found

asked 2021-03-24 15:33:33 -0500

ap2u gravatar image

updated 2021-03-25 14:27:54 -0500

I am trying to use a library that uses catkin as its build system, however I do not require the rest of ROS and would prefer to avoid installing it. From catkin's docs it says that it does not depend upon ROS however I cannot find a way to make it work without it. I am on Windows using WSL2 Ubuntu 20.04 and CMake 3.19.

I have built and installed catkin from source and not installed it from pip. I did change the deb names to python3-* instead of just python-*, while installing deps.

My project top level CMake file is:

cmake_minimum_required(VERSION 3.16)
project(uasgroundrisk)
...
find_package(catkin REQUIRED)
...

The find_package call throws the following error:

/usr/bin/cmake -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - Unix Makefiles" <proj>
-- Using CATKIN_DEVEL_PREFIX: <proj>/cmake-build-debug/devel
-- Using CMAKE_PREFIX_PATH: 
-- Found PythonInterp: /usr/bin/python (found suitable version "3.8.5", minimum required is "3") 
-- Using PYTHON_EXECUTABLE: /usr/bin/python
-- Using Debian Python package layout
-- Using empy: /usr/lib/python3/dist-packages/em.py
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: <proj>/cmake-build-debug/test_results
-- Forcing gtest/gmock from source, though one was otherwise available.
-- Found gtest sources under '/usr/src/googletest': gtests will be built
-- Found gmock sources under '/usr/src/googletest': gmock will be built
-- Found PythonInterp: /usr/bin/python (found version "3.8.5") 
-- Using Python nosetests: /usr/bin/nosetests3
-- catkin 0.8.9
-- BUILD_SHARED_LIBS is on
Traceback (most recent call last):
  File "<proj>/cmake-build-debug/catkin_generated/generate_cached_setup.py", line 12, in <module>
    from catkin.environment_cache import generate_environment_script
ModuleNotFoundError: No module named 'catkin.environment_cache'

I am using Python 3 at /usr/bin/python with this symlinked to the proper location which is being used.

$ which python
  /usr/bin/python
$ ls -la /usr/bin | grep python
 ...
 lrwxrwxrwx 1 root   root           7 Mar 24 15:21 python -> python3
 ...

Spinning up an interactive python console for this same binary

$ python
 Python 3.8.5 (default, Jan 27 2021, 15:41:15)
 [GCC 9.3.0] on linux
 Type "help", "copyright", "credits" or "license" for more information.
 >>> import catkin_pkg
 >>> print(catkin_pkg.__file__)
 /usr/lib/python3/dist-packages/catkin_pkg/__init__.py
 >>> catkin_pkg.__version__
 '0.4.23'
 >>> import sys
 >>> sys.path
 ['/usr/lib/python38.zip', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/usr/local/lib/python3.8/dist-packages', '/usr/lib/python3/dist-packages']

This shows that catkin_pkg is there and up to date. The python path does search through /usr/lib/python3/dist-packages which is where catkin python package is. However:

  >>> import catkin.environment_cache import generate_environment_script
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
  ModuleNotFoundError: No module named 'catkin.environment_cache'

I suspect this is an environment issue, but I am not sure what environment variables catkin is looking for from the CMake side. As I mentioned, I am using it outside of ROS, so have not run sourced the setup.sh files or run rosdep. Do I need to recreate this within my own CMake script?

edit retag flag offensive close merge delete

Comments

catkin != catkin_pkg. Those are two different Python packages.

I have built and installed catkin from source and not installed it from pip

why?

gvdhoorn gravatar image gvdhoorn  ( 2021-03-25 03:59:47 -0500 )edit

It would be great if you could answer my question about why you "built [..] catkin from source and not installed it from pip".

I suspect this is an environment issue, but I am not sure what environment variables catkin is looking for from the CMake side. As I mentioned, I am using it outside of ROS, so have not run sourced the setup.sh files or run rosdep. Do I need to recreate this within my own CMake script?

this is all plain Python at this point.

Do you have the catkin package installed? What is the output of pip list | grep catkin?

gvdhoorn gravatar image gvdhoorn  ( 2021-03-26 01:27:13 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-03-27 09:02:15 -0500

ap2u gravatar image

Running

sudo apt-get install python3-catkin

fixed the issue. As @gvdhoorn comments catkin != catkin_pkg.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2021-03-24 15:26:12 -0500

Seen: 2,388 times

Last updated: Mar 27 '21