我在终端上使用命令来运行这个脚本(plot_test.py 是文件名):
#python3
import pybullet as p
import pybullet_data as p_data
import time
import matplotlib.pyplot as plt
import numpy as np #to reshape for matplotlib
import os
import matplotlib.animation as animation
# os.environ['MESA_GL_VERSION_OVERRIDE'] = '3.3'
# os.environ['MESA_GLSL_VERSION_OVERRIDE'] = '330'
fig = plt.figure()
ax1 = fig.add_subplot(1,1,1)
# plt.ion()
# GUI = 0
def animate(i):
graph_data = open('solved_states.bin','r').read()
lines = graph_data.split('\n')
time_stamp = [] #time
torque = [] #torque
for line in lines:
if len(line) > 1:
x, y = line.split(',')
time_stamp.append(float(y))
torque.append(float(x))
ax1.clear()
ax1.plot(time_stamp, torque,color='r',label='Torque')
ax1.set_title('Torque Vs Time')
ax1.set_xlabel('Time')
ax1.set_ylabel('Torque')
ax1.legend(loc="upper right")
ani = animation.FuncAnimation(fig, animate, interval=1000)
plt.show()
尽管它绘制了图表,但我不断收到此错误:
pybullet build time: Oct 8 2020 00:10:04
/usr/bin/python3: Error while finding module specification for 'plot_test.py' (AttributeError: module 'plot_test' has no attribute '__path__')
我是 python 新手,我不知道它是如何工作的
我以前见过类似的问题,但是在这里,我正在处理的文件显示了错误。