Robotics StackExchange | Archived questions

ImportError: No module named queue

In the Hello World tutorial: http://wiki.ros.org/rosserial_arduino/Tutorials/Hello%20World When trying to initialize rosserial with rosrun rosserialpython serialnode.py /dev/ttyACM0 I get: "ImportError: No module named queue." Any idea what's going on here? ROS Melodic on Ubuntu Bionic

Asked by weterpellman on 2020-09-21 23:47:11 UTC

Comments

I got this problem too, there seems to be very limited answers regarding to this. Did you come uo with a solution yet?

Asked by Erikkk on 2020-10-19 04:26:33 UTC

Yes, please see the solution on this post once it gets moderated!

Asked by weterpellman on 2020-10-19 14:34:05 UTC

this works for me, thanks!

Asked by Erikkk on 2020-10-20 08:58:12 UTC

Answers

The error is showing that in SerialClient.py, line 41 imports the queue module, but apparently there can be a version mismatch between python 2/3 calling the module "Queue" vs "queue".

In your catkin workspace, src/rosserial/rosserial_python/src/rosserial_python/SerialClient.py, try changing the line "import queue" to the following:

try: 
    import queue
except ImportError:
    import Queue as queue

Asked by weterpellman on 2020-10-19 14:33:31 UTC

Comments

Thank you, it worked like a charm for me on ROS Melodic.

Asked by Marcus Barnet on 2021-05-12 14:07:34 UTC