ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

rosserial module SerialClient not found

asked 2020-06-11 11:12:08 -0600

GUENNI gravatar image

updated 2020-06-18 07:00:55 -0600

Following rosserial_arduino tutorial I entered the command rosrun rosserial_python /dev/ttyACM0.

Following error occured:

Traceback (most recent call last):
  File "/home/guenther/catkin_ws/install/lib/rosserial_python/", line 39, in <module>
    from rosserial_python import SerialClient, RosSerialServer
  File "/home/guenther/catkin_ws/install/lib/python3/dist-packages/rosserial_python/", line 1, in <module>
    from SerialClient import *
ModuleNotFoundError: No module named 'SerialClient'

I am using ROS noetic. The tutorial is also for noetic. Source of rosserial is of noetic-devel branch. This ist my ROS environment



I found several questions about this issue, but nothing helped.

Added tries for further investigation:

/home/guenther/catkin_ws is a softlink to /KubuntuDaten/catkin_ws

$PYTHONPATH without sourcing


sys.path in python3
['', '/KubuntuDaten/catkin_ws/install/lib/python3/dist-packages', '/home/guenther/catkin_ws/install/lib/python3/dist-packages', '/opt/ros/noetic/lib/python3/dist-packages', '/KubuntuDaten/catkin_ws/devel/lib/python3/dist-packages', '/home/guenther/catkin_ws/devel/lib/python3/dist-packages', '/usr/lib/', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/home/guenther/.platformio/penv/lib/python3.8/site-packages']

>>> from SerialClient import *
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'SerialClient'

Added rosserial_python to the PYTHONPATH gives:

Python 3.8.2 (default, Apr 27 2020, 15:53:34)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print (sys.path)
['', '/KubuntuDaten/catkin_ws/install/lib/python3/dist-packages/rosserial_python', '/KubuntuDaten/catkin_ws/install/lib/python3/dist-packages', '/home/guenther/catkin_ws/install/lib/python3/dist-packages', '/opt/ros/noetic/lib/python3/dist-packages', '/KubuntuDaten/catkin_ws/devel/lib/python3/dist-packages', '/home/guenther/catkin_ws/devel/lib/python3/dist-packages', '/usr/lib/', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/home/guenther/.platformio/penv/lib/python3.8/site-packages']
>>> from SerialClient import *
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/KubuntuDaten/catkin_ws/install/lib/python3/dist-packages/rosserial_python/", line 42, in <module>
    import StringIO
ModuleNotFoundError: No module named 'StringIO'

I replaced StringIO by io which leaded to the next missing module Queue. This shows that SerialClient looks for Python2 modules, which are not on the PYTHONPATH.

Adding /usr/lib/python2.7 to the PYTHONPATH leads to following error, when starting python3:

Python path configuration:
  PYTHONHOME = (not set)
  PYTHONPATH = '/usr/lib/python2.7:/KubuntuDaten/catkin_ws/install/lib/python3/dist-packages/rosserial_python:/KubuntuDaten ...
edit retag flag offensive close merge delete


Thank you for the editing. How can I see the sourcecode of the posting. So that I can write it next time better.

GUENNI gravatar image GUENNI  ( 2020-06-11 14:55:31 -0600 )edit

Just click the edit button/link below your question.

gvdhoorn gravatar image gvdhoorn  ( 2020-06-12 02:32:52 -0600 )edit

Thanks a lot.

GUENNI gravatar image GUENNI  ( 2020-06-12 02:42:36 -0600 )edit

Further investigation of this issue shows me that there must be a problem with PYTHONPATH and the mix between python2 and python3. I have documented the steps I have taken. Is there a way to add the textfile with the documented steps?

GUENNI gravatar image GUENNI  ( 2020-06-18 06:42:03 -0600 )edit


I suggest you copy-paste the contents and append it to your original question.

gvdhoorn gravatar image gvdhoorn  ( 2020-06-18 06:47:10 -0600 )edit

gvdhoorn, I saw, you commented another question link text about mixing python2 and python3 nodes. This seems to me a similar situation as with my question. Only the main environment in noetic is python3.8 and the rosserial_python has to run under python2.7. Is there a defined way to handle this situation? Is it possible to contact the maintainer of the rosserial package?

In the meantime, I managed to solve the import issues, but then there rises other exceptions when starting the node.

GUENNI gravatar image GUENNI  ( 2020-06-19 15:15:06 -0600 )edit

Please see the rosserial issue tracker. Specifically ros-drivers/rosserial#499.

gvdhoorn gravatar image gvdhoorn  ( 2020-06-19 15:29:57 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2020-06-29 04:51:45 -0600

GUENNI gravatar image

To find a solution for my issue, I decided to switch from the rosserial_python server version to the C++ version of rosserial_server. There I first ran in a new situation, that no connection between my arduino client and the server could be established. The reason was, that rosserial_server sends a hangup signal through the serial line every time it opens the interface, which continuously resets the arduino.The solution is to inhibit the hangup signal with stty -F /dev/ttyACM0 -hupcl. I added this command to <par> {catkin_ws}/src/rosserial/rosserial_server/src/serial_node.cpp

int main(int argc, char* argv[])
  ros::init(argc, argv, "rosserial_server_serial_node");

  std::string port;
  int baud;
  ros::param::param<std::string>("~port", port, "/dev/ttyACM0");
  ros::param::param<int>("~baud", baud, 57600);
  system ("stty -F /dev/ttyACM0 -hupcl"); // Added to inhibit hangup signal

  boost::asio::io_service io_service;
  rosserial_server::SerialSession serial_session(io_service, port, baud);;
  return 0;
edit flag offensive delete link more


Thanks man, it worked here helped me a lot.

0113wesley gravatar image 0113wesley  ( 2020-11-21 10:06:41 -0600 )edit

Hi @0113wesley, I'm glad that I could help you.

GUENNI gravatar image GUENNI  ( 2020-11-25 04:56:54 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2020-06-11 11:12:08 -0600

Seen: 1,220 times

Last updated: Jun 29 '20