我一直在尝试使用Carla自动驾驶汽车环境,但当我尝试运行本教程中的代码时,我遇到了"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:\Downloads\CARLA_0.9.9.4\WindowsNoEditor\PythonAPI\carla\dist\carla-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!")‘仅供参考,我运行的是装有anaconda3和Python3.7.7的Windows10,我使用的是carla版本0.9.9.4。提前感谢!
发布于 2020-08-24 17:58:09
只需更正您的文件夹路径。需要重命名文件结构中的路径,如下所示...
全部删除“。从小路上。
path = glob.glob('C:\Downloads\CARLA_0994\WindowsNoEditor\PythonAPI\carla\dist\carla-099-py37-win-amd64.egg')[0]
sys.path.append(path)完整示例:
import glob
import os
import sys
try:
path = glob.glob('C:\Downloads\CARLA_0994\WindowsNoEditor\PythonAPI\carla\dist\carla-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!")https://stackoverflow.com/questions/63229403
复制相似问题