carla-simulator / carla

Open-source simulator for autonomous driving research.
http://carla.org
MIT License
10.83k stars 3.48k forks source link

Version Mismatch and Segmentation Fault Error on Running generate_traffic.py #6823

Closed i-kj closed 9 months ago

i-kj commented 9 months ago

I built CARLA from source following the instructions on the official build page. However, when I run the generate_traffic.py script from the PythonAPI/examples directory, I encounter a version mismatch warning and a segmentation fault error:

WARNING: Version mismatch detected: You are trying to connect to a simulator that might be incompatible with this API
WARNING: Client API version     = 0.9.13
WARNING: Simulator API version  = 0.9.14-6-g43b5e7064
Segmentation fault (core dumped)

My system is using Python 3.8.10, and the .egg file in PythonAPI/carla/dist is carla-0.9.14-py3.8-linux-x86_64.egg. The script generate_traffic.py accesses the .egg file as follows:

try:
    sys.path.append(glob.glob('../carla/dist/carla-*%d.%d-%s.egg' % (
        sys.version_info.major,
        sys.version_info.minor,
        'win-amd64' if os.name == 'nt' else 'linux-x86_64'))[0])
except IndexError:
    pass

Any assistance in resolving these issues would be greatly appreciated!

i-kj commented 9 months ago

Solution: Ensure the correct .egg file is in the PYTHONPATH. In my case I had 0.9.13 .egg file in the PYTHONPATH as a part of my previous installation. Since I installed 0.9.14 now, whenever I run the API, it will pick up 0.9.13 .egg file as long as I either replace or append the PYTHONPATH with the new egg file. Since I also wanted 0.9.13 version, I chose append option.

Run the following command in the terminal to append:

_export PYTHONPATH=$PYTHONPATH:/path/to/carla/PythonAPI/carla/dist/carla-0.9.14-py3.8-linux-x8664.egg

If you want to replace a path:

export PYTHONPATH=/new/path

Please adjust the /path/to/carla/ to your actual CARLA path.