ROS Python-Own service import error

error

There was an error that the library of my service could not be loaded in the Python node

my_server.py


...

from my_servs.srv import *

...

error


Traceback (most recent call last):
  File "/home/hoshina/catkin_ws/src/pca_server/scripts/pca_server.py", line 3, in <module>
    from pca_server_srvs.srv import *
ModuleNotFoundError: No module named 'pca_server_srvs'

Check if the python library for service is generated

ls ~/catkin_ws/devel/lib/python3/dist-packages 

>> my_srvs 
Okay if generated

>> 
Nothing should come out

Build the following sample and check if the service library is generated https://github.com/fairlight1337/ros_service_examples

git clone https://github.com/fairlight1337/ros_service_examples.git

catkin build

ls ~/catkin_ws/devel/lib/python3/dist-packages 

>> ros_service_examples
Okay,CMakeLists in this repository.txt and package.Refer to xml and modify your own

If the error does not go away

Add the following to python and check if the library path is in

import sys
print(sys.path)

If the pass does not pass

source ~/catkin_ws/devel/setup.bash

Or restart the terminal

environment

Recommended Posts

ROS Python-Own service import error
scikit-learn import error
Resolve VS Code unresolved import error
About import error of PyQt5.QtWidgets (Anaconda)