Carla: ModuleNotFoundError: No module named 'carla'

Created on 30 Mar 2019  路  9Comments  路  Source: carla-simulator/carla

OS: Windwos 10 18865
Carla: 0.9.4

Hi,

I encountered the error ModuleNotFoundError: No module named 'carla' when trying to execute the command python spawn_npc.py -n 80 as suggested by the document. After a little research, I become aware that I'll need to easy_install the .egg file in PythonAPI folder. However, it has a dependencies that Processing dependencies for carla==0.9.4 which made it fail again. What shall I do next?

stale

Most helpful comment

I had a similar issue in a conda enviroment. This was my solution:

  • locate .egg-files in Carla/PythonAPI/carla/dist/
  • change/install python version in conda enviroment which fits closest to an .egg-file (for me carla-0.9.6-py3.5-linux-x86_64.egg -> 3.5)
  • delete all other .egg-files (just for tidiness)
  • extract your .egg-file, e.g. carla-0.9.6-py3.5-linux-x86_64
  • create 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'],
      )
  • then you can install the carla-python-package via pip:
    pip install -e ~/Carla/PythonAPI/carla/dist/carla-0.9.6-py3.5-linux-x86_64

That 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.

All 9 comments

I double checked, it seems that I'm using Python 3.6 as CNTK does not support 3.7 yet. However, carla does not support 3.6?

You need to import the carla, try to make sure the script include the
import glob import os import sys 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 import carla
part. and make sure the '../carla/dist/carla-*%d.%d-%s.egg' path right .
hope this will help you.

In Ubuntu Bionic (18.04) and python 3.6 os.name reports as 'posix'
can we add posix as additional condition to be compatible with the latest version ?

Hey Guys
I add this comment because I spent too much time on this issue .I try to change the sys.path.append and experiment a couple of other things...
At the this end , I realize that there are 2 eggs ( zip files in carla/dist ) one for python 2.7 and one for python 3.5 and therefore you have to run the python client script with one of these distributions. Then all is fine .... :) .
I am pretty sure it is somewhere written in the doc ....

@remitoudic - Thanks for the answer. I realized the same. I unzipped the distribution (based on my python version) I needed and placed in the my path.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

I had a similar issue in a conda enviroment. This was my solution:

  • locate .egg-files in Carla/PythonAPI/carla/dist/
  • change/install python version in conda enviroment which fits closest to an .egg-file (for me carla-0.9.6-py3.5-linux-x86_64.egg -> 3.5)
  • delete all other .egg-files (just for tidiness)
  • extract your .egg-file, e.g. carla-0.9.6-py3.5-linux-x86_64
  • create 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'],
      )
  • then you can install the carla-python-package via pip:
    pip install -e ~/Carla/PythonAPI/carla/dist/carla-0.9.6-py3.5-linux-x86_64

That 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.

You either need to write your script dirercty where you extracted carla. In that case the part sys.path.append(glob.glob('../carla/dist/carla-*%d.%d-%s.egg'... will detect carla path in your environment variables.

Or change the path in sys.path.append(glob.glob('../carla/dist/carla-*%d.%d-%s.egg'... to directrly point to where you extracted carla.

A cleaner way would be to copy '../carla/dist/carla-*%d.%d-%s.egg' in your python site pachkages, then you can import it normally anywhere you are developing your script.

Did you guys check out sentdex's video?
https://www.youtube.com/watch?v=J1F32aVSYaU&list=PLQVvvaa0QuDeI12McNQdnTlWz9XlCa0uo

He uses:
py -3.7 python spawn_npc.py -n 80

Was this page helpful?
0 / 5 - 0 ratings

Related issues

robertnishihara picture robertnishihara  路  4Comments

kk2491 picture kk2491  路  3Comments

jinfagang picture jinfagang  路  3Comments

metaluga145 picture metaluga145  路  4Comments

kartikye picture kartikye  路  3Comments