I am using ros1 noetic on Winodws 10 I wrote my nodes in python. but these nodes depends on -import functions from or use classed from or use date from - other python scripts , dlls, csv ..etc. files. when I try run my nodes, I get error that a service module is not found
[INFO] [1725469146.826745]: MyNode node has been created
Traceback (most recent call last):
File "Path to python scripts \Printer.py", line 15, in <module>
exec(compile(fh.read(), python_script, 'exec'), context)
File "path to python scripts/Printer.py", line 16, in <module>
_myObj = MyClass()
NameError: name 'MyClass' is not defined
im My CMakeFiles.txt I added my class script using
catkin_install_python(PROGRAMS
scripts/MyClass.py
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
and using
install(FILES
scripts/MyClass.py
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
How to overcome this problem and make all dependencies accessible for my node
ros2 colcon update
I get similar error on ros2 as well
Traceback (most recent call last):
File "...\ros2_ws\install\lib\MyPackage\execName-script.py", line 33, in <module>
sys.exit(load_entry_point('MyPackage', 'console_scripts', 'execName')())
File "...\ros2_ws\install\lib\MyPackage\execName-script.py", line 25, in importlib_load_entry_point
return next(matches).load()
File "c:\python38\lib\importlib\metadata.py", line 77, in load
module = import_module(match.group('module'))
File "c:\python38\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "...\ros2_ws\build\MyPackage\MyPackage\MyScript.py", line 4, in <module>
from SupportModule import *
ModuleNotFoundError: No module named 'SupportModule'
[ros2run]: Process exited with failure 1
I tried to put SupportModule within the depend modules in package.xml, but it didn't help
<depend>SupportModule</depend>
How to solve this problem?