我一直在尝试使用卡拉自动驾驶汽车环境,但我遇到了"AttributeError:模块"carla"没有属性"Client"当我尝试运行本教程中的代码时:https://pythonprogramming.net/control-camera-sensor-self-driving-autonomous-cars-carla-python/.我对代码做了一些更改,包括将.egg文件更改为我电脑中的确切文件路径。
这是我的密码。。。
'''
import glob
import os
import sys
try:
sys.path.append(glob.glob('C:DownloadsCARLA_0.9.9.4WindowsNoEditorPythonAPIcarladistcarla-0.9.9-py3.7-win-amd64.egg'))
except IndexError:
pass
import carla
actor_list = []
#try:
client = carla.Client("localhost", 2000)
client.set_timeout(2.0)
world = client.get_world()
blueprint_library = world.get_blueprint_library()
#finally:
for actor in actor_list:
actor.destroy()
print("All cleaned up!")
"仅供参考,我在windows 10上运行,它有anaconda3和python 3.7.7,我使用的是carla 0.9.9.4版本。提前感谢!
只需更正文件夹路径即可需要像这样重命名文件结构中的路径。。。
全部删除"从路径。
path = glob.glob('C:DownloadsCARLA_0994WindowsNoEditorPythonAPIcarladistcarla-099-py37-win-amd64.egg')[0]
sys.path.append(path)
完整示例:
import glob
import os
import sys
try:
path = glob.glob('C:DownloadsCARLA_0994WindowsNoEditorPythonAPIcarladistcarla-099-py37-win-amd64.egg')[0]
sys.path.append(path)
except IndexError:
pass
import carla
actor_list = []
try:
client = carla.Client("localhost", 2000)
client.set_timeout(5.0)
world = client.get_world()
blueprint_library = world.get_blueprint_library()
print("Map = ", world.get_map())
finally:
for actor in actor_list:
actor.destroy()
print("All cleaned up!")