Chapter 2 Deep Learning Basics - No module 'Utilities'

Hi,
I tried to run the following code in move_robot/src package.

import pandas as pd
from utilities import plot_points
df = pd.read_csv(’/home/user/catkin_ws/src/velocity_data.csv’,sep=’,’)
t = df[‘field.header.stamp’].astype(float)
t = t / df[‘field.header.stamp’].iloc[0]
X = df[‘field.pose.pose.position.x’].astype(float)

plot the points

plot_points(t,X,‘X(t)’)

It shows following error. How can I rectify it.

user:~/catkin_ws$ rosrun move_robot runcell.py
Traceback (most recent call last):
File “/home/user/catkin_ws/src/dlrepo/move_robot/src/runcell.py”, line 3, in
from utilities import plot_points
ModuleNotFoundError: No module named ‘utilities’

Hey

Your error is in this line:

from utilities import plot_points

There is not such package in python.

If you got a code from some github repository, they probably have a utilities.py file somewhere, so you can download it and place it on your folder.

In any case, good luck for you!

Thank you. But in my case, utilities.py is available in this package. still it is getting error.

Aaaw I see.

Well I’m not an expert but if everything is placed correctly on its respective folders I can only think about the steps of compiling (catkin_make or catkin_build) and source devel/setup.bash right after.

If you also did that and are still getting the error it will be me and you curious for knowing the answer haha

Fina. Actually, I have downloaded package from git. then they have mentioned to do following steps.

You should now see the following folders, /dl_scripts, /utilities and /dl_exercises, appear in your catkin workspace.
Run the following cell to set the path for all the plots you are going to use in this chapter:

  1. =========================
    import sys
    sys.path.append(’/home/user/catkin_ws/src/dlrepo/utilities’)
    =========================
  2. =======================
    import pandas as pd
    from utilities import plot_points
    df = pd.read_csv(’/home/user/catkin_ws/src/velocity_data.csv’,sep=’,’)
    t = df[‘field.header.stamp’].astype(float)
    t = t / df[‘field.header.stamp’].iloc[0]
    X = df[‘field.pose.pose.position.x’].astype(float)

plot the points

plot_points(t,X,‘X(t)’)

I don’t know where should I place the above code and run. But I tried to run the code in one of the package named move_robot in the name of runcell.py. But I am getting error.

It is working, I placed that utilities.py file in different folder. You are right. It should be in same package. Thank you.

2 Likes