Ros uses python3 venv instead of python2 dirs to look for packages
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):
execute_process(/home/work/py_venv/bin/python
"/opt/ros/kinetic/share/catkin/cmake/parse_package_xml.py"...
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.
You might want to try removing the
build
anddevel
folder from your workspace, closing the shell, starting a new one and trying again.Quite a few variables are cached in the
build
anddevel
folders, so removing them after changing locations/versions of things is a good thing to do.This is something I tried before. It did not help unfortunately.
Then it would seem the python venv is still active, or your environment variables still point to it.
Also not in your
.bashrc
(if you're usingbash
)?I had the same issue. I now operate from a conda environment with python2 installed. I'm now a peaceful person!