module '<file_name>' has no attribute '__path__'

239 views Asked by At

I'm using commands on terminal to run this script (plot_test.py is the name of the file):

#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()

Altough it plots the graph and, I keep getting this error:

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__')

I'm new to python and I don't know how this works

I've seen similar questions like this before, but here, the file that I am working on is showing up the error.

1

There are 1 answers

1
michalbargiel On BEST ANSWER

Are you running the file with command

python -m plot_test.py

?

The flag -m runs the file as a module and then you need to omit the .py

If my assumption is true then you should be good with either:

python -m plot_test

or simply

python plot_test.py