Hey there,
the default python version I use on my Ubuntu 16.04 machine is 3.6 (Anaconda) and I'm trying to setup my catkin workspace. When I run catkin_make
, I get an error that has been described in a few other questions here (such as here and here):
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.
The suggestions in the other questions don't help me, as this is about a more general problem:
How can I run ROS (Kinetic in my case) when my default python version is 3.x?
I want to make it so that ROS uses python 2.7, but I want to keep python 3.6 as my default python version.
Is that possible? If yes, how do I do that?
This is my default python version:
$ python -V
Python 3.6.0 :: Anaconda 4.3.1 (64-bit)
And my sys.path:
$ python -c 'import sys; print(sys.path)'
['', '/opt/ros/kinetic/lib/python2.7/dist-packages', '/home/xyz/anaconda3/lib/python36.zip', '/home/xyz/anaconda3/lib/python3.6', '/home/xyz/anaconda3/lib/python3.6/lib-dynload', '/home/xyz/anaconda3/lib/python3.6/site-packages', '/home/xyz/anaconda3/lib/python3.6/site-packages/Sphinx-1.5.1-py3.6.egg', '/home/xyz/anaconda3/lib/python3.6/site-packages/setuptools-27.2.0-py3.6.egg']
I tried to simply add /usr/lib/python2.7/
to my ~/.bashrc
, but that doesn't work. I can't even source the .bashrc
because of syntax errors in all files with python 2 syntax.
My logic was that if I simply add all python directories, version 2.x and 3.x, to my PYTHONPATH, then any application (such as ROS) can always find the right modules it needs. But it doesn't seem to work like that, or at least simply adding python paths to .bashrc.
doesn't work.
Weirdly, the path '/opt/ros/kinetic/lib/python2.7/dist-packages'
is already in there, but it is /usr/lib/python2.7/dist-packages
that contains catkin_pkg
and some other important packages and modules.
Any help is very much appreciated!
Originally posted by alexe on ROS Answers with karma: 60 on 2017-04-17
Post score: 2