Carla ros bridge: ImportError: No module named util

hello, i face a error when run roslaunch carla_ros_bridge carla_ros_bridge.launch

Traceback (most recent call last):
  File "/home/zqw/carla-ros-bridge/catkin_ws/src/ros-bridge/carla_ros_bridge/src/carla_ros_bridge/bridge.py", line 37, in <module>
    import carla
  File "/home/zqw/carla/PythonAPI/carla/dist/carla-0.9.10-py3.6-linux-x86_64.egg/carla/__init__.py", line 8, in <module>
    
  File "/home/zqw/carla/PythonAPI/carla/dist/carla-0.9.10-py3.6-linux-x86_64.egg/carla/libcarla.py", line 9, in <module>
  File "/home/zqw/carla/PythonAPI/carla/dist/carla-0.9.10-py3.6-linux-x86_64.egg/carla/libcarla.py", line 3, in __bootstrap__
ImportError: No module named util

and i use carla 0.9.10 and Unreal 4.24.

Hi!
Are you using ROS melodic? If you are using ROS melodic you need to add the Python2 egg file to your PYTHONPATH and not the Python3 egg file.

can you tell me how i get python2 egg files? i only has a python3 egg file in ./PythonAPI/carla/dist/carla-0.9.10-py3.6-linux-x86_64.egg, very thanks

I just realised you are using 0.9.10 package. I would recommend using 0.9.10.1 instead (https://carla-releases.s3.eu-west-3.amazonaws.com/Linux/CARLA_0.9.10.1.tar.gz). Support for Python2 was dropped in 0.9.10 and added again in 0.9.10.1.

hello, when i reset branch to 0.9.10.1 and it also occur the same erro, and still generate python3 egg file.

Hi! What do you mean by “when a reset branch to 0.9.10.1”? Are you building CARLA from source?

If you are building the PythonAPI from source, you can build it for Python2 in the following way:

make PythonAPI ARGS="--python-version=2"

Also, you can target several python versions:

make PythonAPI ARGS="--python-version=2,3.7,3.6"

On the other hand, if you are using the package (you can download the package for CARLA 0.9.10.1 here: https://carla-releases.s3.eu-west-3.amazonaws.com/Linux/CARLA_0.9.10.1.tar.gz) you will find the egg files for both Python2 and Python3 in the directory: PythonAPI/carla/dist.

Then, you just need to add the Python2 egg file to the PYTHONPATH

very thanks and solved this problem

:+1::+1::+1: