urdf ImportError: No module named 're'

asked 2019-07-02 01:11:31 -0500

joonhyup gravatar image

updated 2019-07-02 01:59:03 -0500

jayess gravatar image

When I tried to typing as follow, to make my first urdf file:

rosrun xacro xacro.py `rospack find pr2_description`/robots/pr2.urdf.xacro -o /tmp/pr2.urdf

I got an error as follow:

Traceback (most recent call last):
  File "/opt/ros/kinetic/share/xacro/xacro.py", line 55, in <module>
    import xacro
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/xacro/__init__.py", line 39, in <module>
    import re
  File "/usr/lib/python3.5/re.py", line 123, in <module>
    import sre_compile
ImportError: No module named 'sre_compile'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 53, in apport_excepthook
    if not enabled():
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 24, in enabled
    import re
ImportError: No module named 're'

Original exception was:

Traceback (most recent call last):
  File "/opt/ros/kinetic/share/xacro/xacro.py", line 55, in <module>
    import xacro
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/xacro/__init__.py", line 39, in <module>
    import re
  File "/usr/lib/python3.5/re.py", line 123, in <module>
    import sre_compile
ImportError: No module named 'sre_compile'

I think it is because import re call the python3, but I don't know how to fix it to call python2 to import re. So, please tell me how to solve the problem?

edit retag flag offensive close merge delete

Comments

Do you have Python 3 set as your default interpreter?

gvdhoorn gravatar image gvdhoorn  ( 2019-07-02 02:33:58 -0500 )edit

No, my default python interpreter is python 2.7.12. When I type 'python' on terminal python 2.7.12 is started.

joonhyup gravatar image joonhyup  ( 2019-07-03 00:43:22 -0500 )edit

Is re installed for python 2?

AndreasLydakis gravatar image AndreasLydakis  ( 2019-07-11 03:33:34 -0500 )edit