Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError: No module named 'carla' #1466

Closed
ZhiyuanChen opened this issue Mar 30, 2019 · 13 comments
Closed

ModuleNotFoundError: No module named 'carla' #1466

ZhiyuanChen opened this issue Mar 30, 2019 · 13 comments
Labels
stale Issue has not had recent activity

Comments

@ZhiyuanChen
Copy link

ZhiyuanChen commented Mar 30, 2019

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?

@ZhiyuanChen
Copy link
Author

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?

@slowergmajor
Copy link

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.

@srikanth-narayanan
Copy link

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 ?

@remitoudic
Copy link

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

@srikanth-narayanan
Copy link

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

@stale
Copy link

stale bot commented Aug 10, 2019

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.

@stale stale bot added the stale Issue has not had recent activity label Aug 10, 2019
@stale stale bot closed this as completed Aug 17, 2019
@autonomobil
Copy link

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.

@RoozbehBandpey
Copy link

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.

@anurag-176
Copy link

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

@leclair-7
Copy link

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.

Thankyou! seems to import cleanly. Now to add to path..

@tetsu-kikuchi
Copy link

tetsu-kikuchi commented Nov 20, 2022

Information as of 20 Nov. 2022.

Related documents are this one and this one.

In my case, carla installation worked in the following steps. I used Ubuntu 20.04, and Carla v0.9.13 in its stand alone mode.

  • Prepare Python version 3.7.xx (I used 3.7.10)
  • Upgrade pip (I used pip 22.3.1)
  • $ cd PythonAPI/carla/dist/
  • $ pip install carla-0.9.13-cp37-cp37m-manylinux_2_27_x86_64.whl

@ishaan95
Copy link

Update as of Feb 18th 2023.

You can directly execute pip install carla==<the version number> to get the python module released on the carla pypi.

@Gowresh-HW
Copy link

Gowresh-HW commented Jun 14, 2023

For anyone facing this issue still, follow this link for a detailed solution:-

https://imtiazulhassan.medium.com/solving-the-modulenotfounderror-no-module-named-carla-error-d18cfb442f67

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Issue has not had recent activity
Projects
None yet
Development

No branches or pull requests