rosserial module SerialClient not found
Following rosserial_arduino tutorial http://wiki.ros.org/rosserial_arduino... I entered the command rosrun rosserial_python serial_node.py /dev/ttyACM0
.
Following error occured:
Traceback (most recent call last):
File "/home/guenther/catkin_ws/install/lib/rosserial_python/serial_node.py", line 39, in <module>
from rosserial_python import SerialClient, RosSerialServer
File "/home/guenther/catkin_ws/install/lib/python3/dist-packages/rosserial_python/__init__.py", 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
ROS_VERSION=1
ROS_PYTHON_VERSION=3
ROS_PACKAGE_PATH=/home/guenther/catkin_ws/install/lib/python3/dist-packages:/home/guenther/catkin_ws/install/share:/opt/ros/noetic/share
ROSLISP_PACKAGE_DIRECTORIES=
ROS_ETC_DIR=/opt/ros/noetic/etc/ros
ROS_MASTER_URI=http://localhost:11311
ROS_ROOT=/opt/ros/noetic/share/ros
ROS_DISTRO=noetic
echo $PYTHONPATH
/home/guenther/catkin_ws/install/lib/python3/dist-packages:/opt/ros/noetic/lib/python3/dist-packages:/home/guenther/catkin_ws/devel/lib/python3/dist-packages
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
/home/guenther/catkin_ws/devel/lib/python3/dist-packages:/opt/ros/noetic/lib/python3/dist-packages
$PYTHONPATH sourced
/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
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/python38.zip', '/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/python38.zip', '/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/SerialClient.py", 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 ...
Thank you for the editing. How can I see the sourcecode of the posting. So that I can write it next time better.
Just click the
edit
button/link below your question.Thanks a lot.
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?
No.
I suggest you copy-paste the contents and append it to your original question.
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.
Please see the
rosserial
issue tracker. Specifically ros-drivers/rosserial#499.