rosrun rqt_graph rqt_graph Attribute Error: module 'enum' has no attribute 'IntFlag'
Hi.
I am a brand new ROS user, so I'm going through the tutorials and have run into an error I can't figure out. I am on step 2.1 in this tutorial: http://wiki.ros.org/ROS/Tutorials/Und.... I am using ros melodic on Ubuntu 18.04.5.
:~$ env | grep ROS
ROS_ETC_DIR=/opt/ros/melodic/etc/ros
ROS_ROOT=/opt/ros/melodic/share/ros
ROS_MASTER_URI=http://localhost:#####
ROS_VERSION=1
ROS_PYTHON_VERSION=2
ROS_PACKAGE_PATH=/opt/ros/melodic/share
ROSLISP_PACKAGE_DIRECTORIES=
ROS_DISTRO=melodic
This is the error I get:
:~$ rosrun rqt_graph rqt_graph
Traceback (most recent call last):
File "/opt/ros/melodic/lib/rqt_graph/rqt_graph", line 5, in <module>
from rqt_gui.main import Main
File "/opt/ros/melodic/lib/python2.7/dist-packages/rqt_gui/main.py", line 38, in <module>
from qt_gui.main import Main as Base
File "/opt/ros/melodic/lib/python2.7/dist-packages/qt_gui/main.py", line 35, in <module>
from argparse import ArgumentParser, SUPPRESS
File "/home/zippyzoo77/anaconda3/lib/python3.8/argparse.py", line 88, in <module>
import re as _re
File "/home/zippyzoo77/anaconda3/lib/python3.8/re.py", line 145, in <module>
class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
If you inspect the traceback, you'll notice
argparse
is being imported from Python3 and not Python2. #q350755 is another similar issue as yours. What are your outputs towhich python
andpython --version
(answer to #q342710)?Given the fact we see this in the traceback:
it's likely the OP has Anaconda installed.
which python
will probably return a path somewhere in/home/zippyzoo77/anaconda3/
.It's indeed a Python 2 vs Python 3 problem.
Indeed, my machine has python 3.8.5 installed through anaconda (which I use for other things as well, and need to stay where it is) which python returns /home/zippyzoo77/anaconda3/bin/python and the python version returns 3.8.5
I have never had anything python 2 on the machine and am trying to do this with python 3, since python 2 is at end of life and I already have the python 3.
That could be, but ROS Melodic does not support Python 3.
So:
I doubt that is true, unless you built Melodic yourself, from source, and forced it to use Python 3.
Does installing melodic automatically install python 2 as well then? I would like to do the build from source for python 3, I thought that is what I had done, but maybe not? I don't know, but I'm really confused and just want to be able to run everything, preferably without having to completely start over.
In
bashrc
, have you tried commenting out the PATH that points to Anaconda?I couldn't get it figured out, the correct answer seems to be to completely rebuild the machine to use ubuntu 20 and get noetic instead.
If you want/need to use Python 3 with ROS nodes, then that would indeed be the most supported option, as all of ROS will then also natively use Python 3.