ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

rosserial "NameError: name 'client' is not defined"

asked 2020-10-19 08:52:21 -0500

Erikkk gravatar image

I am very new to ROS and Arduino, I am trying to use rosserial to realize the communication between my computer and Arduino. I can upload the program to Arduino successfully. But when I run rosserial_python,there is error:

ImportError: No module named queue

I changed import queue into import Queue in file, then new error appear as:

[INFO] [1603106570.886915]: ROS Serial Python Node
[INFO] [1603106570.897550]: Connecting to /dev/ttyACM0 at 57600 baud
[WARN] [1603106570.900234]: Unexpected Error: <type 'exceptions.NameError'>
Traceback (most recent call last):

  File "/home/xiao/catkin_ws/src/rosserial/rosserial_python/nodes/", line 99, in <module>
NameError: name 'client' is not defined

So what is the problem here? how should I fix it? Thanks for any advice

edit retag flag offensive close merge delete


Add the relevant code please.

JackB gravatar image JackB  ( 2020-10-19 11:57:53 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2020-10-20 09:03:42 -0500

Erikkk gravatar image

The problem is solved by replace

import queue


import Queue as queue

The first time I just replaced queue with Queue but the remaining program is still using queue this is why the second error comes out.

edit flag offensive delete link more



I have the same problem, i replace import queue by import Queue as queue but I have the same error message.

Could you help, thank you

hyakoubi gravatar image hyakoubi  ( 2021-10-16 09:08:11 -0500 )edit

This is not a good fix. The better solution would be to use python2 like the developers intended. You can sometimes get away with using python3 in melodic, but it can lead to very puzzling errors if you ever modify this node in the future.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2021-10-18 08:22:33 -0500 )edit

answered 2020-10-19 13:46:49 -0500

duck-development gravatar image

Can you run sudo pip3 install py serial to install the proper python serial port library.

Do you run it with phython3?

Because melodic uses python3 and in python3 the queue is wirttten with a capital letter Queue. So it was right.

Did you run the node with ros run or lauchfile?

Did you source your workspace and the /opt/ros/meldic/.... Setup. Bash file?

edit flag offensive delete link more


melodic uses python2, not python3.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2021-10-18 08:16:26 -0500 )edit

Question Tools

1 follower


Asked: 2020-10-19 08:52:21 -0500

Seen: 2,560 times

Last updated: Oct 16 '21