I have a ROS 1 workspace where one of the nodes is currenly having issues importing things.
My file structure looks like this
catkin_ws/├── src/│└── MyPackage/│├── CMakeLists.txt│├── package.xml│├── scripts/││└── file1.py│└── src/│└── file2.py
I have set file1.py to an executable with chmod +x and have not done this to file2.py.
file1.py is trying to do from file2 import someclass
but it cannot find file2 and gives me
Traceback (most recent call last): File "/root/catkin_ws/devel/lib/MyPackage/file1.py", line 15, in <module> exec(compile(fh.read(), python_script, 'exec'), context) File "/root/catkin_ws/src/MyPackage/scripts/file1.py", line 14, in <module> from file2 import someclassModuleNotFoundError: No module named 'file2'
Here is my CMakeLists.txt
cmake_minimum_required(VERSION 3.0.2)project(MyPackage)find_package(catkin REQUIRED COMPONENTS roscpp rospy std_msgs)catkin_package( CATKIN_DEPENDS roscpp rospy std_msgs)include_directories(# include ${catkin_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/src)catkin_install_python(PROGRAMS scripts/file1.py DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})install(DIRECTORY src/ DESTINATION ${CATKIN_PACKAGE_PYTHON_DESTINATION})
And here is package.xml
<?xml version="1.0"?><package format="2"><name>MyPackage</name><version>0.0.0</version><description>The MyPackage package</description><buildtool_depend>catkin</buildtool_depend><build_depend>roscpp</build_depend><build_depend>rospy</build_depend><build_depend>std_msgs</build_depend><build_export_depend>roscpp</build_export_depend><build_export_depend>rospy</build_export_depend><build_export_depend>std_msgs</build_export_depend><exec_depend>roscpp</exec_depend><exec_depend>rospy</exec_depend><exec_depend>std_msgs</exec_depend><export><build_type>catkin</build_type></export></package>