I downloaded the Pre-Compiled version of CARLA 0.9.1. Extracted it in a directory.
Then I started CARLA in server mode: ./CarlaUE4.sh.
As per the change log of the release - https://github.com/carla-simulator/carla/blob/master/CHANGELOG.md#carla-091
The example.py is now tutorial.py
So, in a new terminal I type: python tutorial.py.
I get the following error:
Traceback (most recent call last):
File "tutorial.py", line 21, in
import carla
File "PythonAPI/carla-0.9.1-py2.7-linux-x86_64.egg/carla/__init__.py", line 7, in
File "PythonAPI/carla-0.9.1-py2.7-linux-x86_64.egg/carla/libcarla.py", line 7, in
File "PythonAPI/carla-0.9.1-py2.7-linux-x86_64.egg/carla/libcarla.py", line 6, in __bootstrap__
ImportError: libpng16.so.16: cannot open shared object file: No such file or directory
I tried running: python manual_control.py.
I get the following error:
Traceback (most recent call last):
File "manual_control.py", line 63, in
from PythonAPI import carla
ImportError: No module named PythonAPI
I am sure I followed all the instructions in the Getting Started page of documentation to word.
https://carla.readthedocs.io/en/latest/getting_started/
Can someone help me with what I am doing wrong?
I think you should to use python3 instead of python2 as Carla9.1 support python3 right now.
Try this
```
sudo apt-get install libpng16-16
````
try this: https://github.com/fcagroupj/fcarsim
@danil-tolkachev Thanks a lot. Your solution solved my problem for running the tutorial.py.
@nsubiron I think this dependency should be added in the documentation.
However I am still getting the error when running the manual_control.py.
Traceback (most recent call last):
File "manual_control.py", line 63, in
from PythonAPI import carla
ImportError: No module named PythonAPI
@Marwa215 I had tried running the scripts on 2.7, 3.5 and 3.6 before posting the issue. However, I was unable to run it.
When I do: python manual_control.py, I get:
Traceback (most recent call last):
File "manual_control.py", line 63, in
from PythonAPI import carla
ImportError: No module named PythonAPI
but, When I do: python3 manual_control.py, I get:
Traceback (most recent call last):
File "manual_control.py", line 63, in
from PythonAPI import carla
ImportError: cannot import name 'carla'
So with python3, its recognizing PythonAPI but unable to import carla from it.
To run the example code - manual_control.py, you also need to go inside PythonAPI directory and extract carla-0.9.1-py3.5-linux-x86_64.egg there.
Then you need to copy the contents of the extracted folder back into PythonAPI directory.
The PythonAPI directory should look like this:
And then I was able to run it by python3 manual_control.py.
The python manual_control.py Still gives the error though:
Things I tried:
export PYTHONPATH=./:PythonAPI/But the error remains the same
@YashBansod Are you sure that you are using right version of manual_control.py? I've checked PythonAPI/manual_control.py (not Deprecated/PythonClient/manual_control.py) and there's no line from PythonAPI import carla.
@danil-tolkachev I downloaded the Pre-Compiled version of CARLA 0.9.1. The manual_control.py in the precompiled version has that line. Its because in the Precompiled version, the manual_control.py is outside the PythonAPI directory.
Finally I found the solution.
I had to create a __init__.py file in the PythonAPI directory to make it work with python2.7. This is required since python2.7 requires the __init__.py file to recognise a directory as a python package.
Note: you do not need to export any Python Path.
@YashBansod It's strange. In the precompiled version (0.9.1 from https://github.com/carla-simulator/carla/releases) I don't see such lines. Also, in the PythonAPI i have *.egg files, so it doesn't require __init_.py.
I had a similar issue in a conda enviroment. This was my solution:
Carla/PythonAPI/carla/dist/setup.py inside the folder (carla-0.9.6-py3.5-linux-x86_64) with the following content:from distutils.core import setup
setup(name='carla',
version='0.9.6', #doesn't matter I guess
py_modules=['carla'],
)
pip install -e ~/Carla/PythonAPI/carla/dist/carla-0.9.6-py3.5-linux-x86_64That solved it for me. I don't even need the egg-path-appending-stuff, which is happening at the beginning of every python-script, just import carla.
Most helpful comment
Try this
```
sudo apt-get install libpng16-16
````