我有一台台式电脑和一个笔记本,当我尝试使用pip install tensorflow 在笔记本上安装 tensorflow 时它工作正常,然后我在台式电脑上尝试了同样的方法,当我尝试运行最简单的代码时:
import tensorflow as tf
from tensorflow.keras import Sequential
print("done")
Run Code Online (Sandbox Code Playgroud)
我收到了这个非常复杂的错误消息:
Traceback (most recent call last):
File "C:\Users\Mechatrnk\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\Mechatrnk\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\Mechatrnk\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "C:\Users\Mechatrnk\AppData\Local\Programs\Python\Python37\lib\imp.py", line 242,
in load_module
return load_dynamic(name, filename, file)
File "C:\Users\Mechatrnk\AppData\Local\Programs\Python\Python37\lib\imp.py", line 342,
in load_dynamic
return _load(spec)
ImportError: DLL load failed: Uvedený modul nebyl …
Run Code Online (Sandbox Code Playgroud) 我正在尝试为每个建筑物绘制一个矩形,该矩形的每一边旁边都有一条边(应该代表一栋有围栏的建筑物),它运行得很好,但是当我尝试添加新建筑物时,它将自己弄乱了完全。
我有以下代码来创建建筑物:
class Building():
def __init__(self, Box_2_World,shape, position, sensor= None):
self.Box_2_World = Box_2_World
self.shape = shape
self.position = position
if sensor == None:
sensor = False
self.sensor = sensor
self.footprint = self.Box_2_World.CreateStaticBody(position = position,
angle = 0.0,
fixtures = b2FixtureDef(
shape = b2PolygonShape(box=(self.shape)),
density = 1000,
friction = 1000))
self.Lower_Fence = self.Box_2_World.CreateStaticBody(position=(self.footprint.position[0],self.footprint.position[1] -1.75*self.shape[1]))
self.Lower_Fence.CreateEdgeChain([(self.Lower_Fence.position[0]-4.25*self.shape[0],self.Lower_Fence.position[1]),
(self.Lower_Fence.position[0]-2.25*self.shape[0],self.Lower_Fence.position[1]),
])
self.Right_Fence = self.Box_2_World.CreateStaticBody(position=(self.footprint.position[0]-1*self.shape[0],self.footprint.position[1]))
self.Right_Fence.CreateEdgeChain([(self.Right_Fence.position[0],self.Right_Fence.position[1] - 1.25*self.shape[1]),
(self.Right_Fence.position[0],self.Right_Fence.position[1]-3.25*self.shape[1]),
])
self.Upper_Fence = self.Box_2_World.CreateStaticBody(position=(self.footprint.position[0],self.footprint.position[1] -0.45* self.shape[1]))
self.Upper_Fence.CreateEdgeChain([(self.Upper_Fence.position[0] - 4.25* self.shape[0],self.Upper_Fence.position[1]),
(self.Upper_Fence.position[0]- 3.25* self.shape[0]+ self.shape[0],self.Upper_Fence.position[1]),
])
self.Left_Fence = …
Run Code Online (Sandbox Code Playgroud) 我有一个 Box2D 世界,圆圈代表行人,正方形代表建筑物,我有一个算法可以找到最近的建筑物,然后它会在边缘转动,但我有一个问题,当它正好在建筑物之间的中间时它会转动,所以算法有点工作,但不是我想要的方式
def pedestrian_walk(pedestrian, buildings):
## Find the building nearest to the pedestrian
list_of_distances = []
for building in buildings:
list_of_distances.append(np.sqrt((pedestrian.body.position[0] - building.footprint.position[0])**2 + (pedestrian.body.position[1] - building.footprint.position[1])**2))
pedestrian.nearest_building= list_of_distances.index(min(list_of_distances))
#print(f"Nearest builing index is: {pedestrian.nearest_building}")
building = buildings[pedestrian.nearest_building]
#Pedestrian walks around the left side of the nearest building
if pedestrian.body.position[0] <= building.position[0] and building.position[1] - building.shape[1] <= pedestrian.position[1] <= building.position[1] + 1.05*building.shape[1]:
pedestrian.body.__SetLinearVelocity(b2Vec2(0,pedestrian.ped_velocity))
print("1st if")
#Pedestrian walks around the right side of the nearest building
elif pedestrian.body.position[0] > building.position[0] and …
Run Code Online (Sandbox Code Playgroud)