Ros uses python3 venv instead of python2 dirs to look for packages

asked 2019-01-03 13:17:54 -0600

Peter1 gravatar image

I recently installed a python3 venv with python3 -m venv Now I get the following error when I want to build my workspace:

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):

I am at the point where I know the problem is the first path, since this refers to the virtual environment, which contains python3 without any ros packages installed. I have however not actively sourced it. So I dont know why it should be active. On the other hand I dont know I could remove it from the path. Removing the folder of the venv alltogether did not help.

edit retag flag offensive close merge delete


You might want to try removing the build and devel folder from your workspace, closing the shell, starting a new one and trying again.

Quite a few variables are cached in the build and devel folders, so removing them after changing locations/versions of things is a good thing to do.

gvdhoorn gravatar image gvdhoorn  ( 2019-01-03 13:27:42 -0600 )edit

This is something I tried before. It did not help unfortunately.

Peter1 gravatar image Peter1  ( 2019-01-04 03:35:02 -0600 )edit

Then it would seem the python venv is still active, or your environment variables still point to it.

I have however not actively sourced it

Also not in your .bashrc (if you're using bash)?

gvdhoorn gravatar image gvdhoorn  ( 2019-01-04 04:28:48 -0600 )edit

I had the same issue. I now operate from a conda environment with python2 installed. I'm now a peaceful person!

robowarrior gravatar image robowarrior  ( 2019-01-04 12:39:20 -0600 )edit