ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A answers.ros.org
Ask Your Question
0

python directory import issue on ROS

asked 2017-08-09 02:51:27 -0500

apanda gravatar image

updated 2017-08-09 02:53:18 -0500

hi all, My ros_workspace directory is like this:

ros_workspace --> src--> package1(src, msg, script((folder1-->abc1.py), ( folder2-->abc2.py))):

I want import "abc2.py" from "abc1.py", how should i write ? I tried "import package1.script.folder2.abc2" from "abc1.py", it is so long for the path, also I use catkin_make under ros_workspace build, the error show "ImportError: No module named scripts.folder2" How should i import the abc2.py from abc1.py ? please don't say "put abc1.py and abc2.py together", this is just a example, I have too many python files, so i need category them to several folder. thanks

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-08-09 03:07:25 -0500

naveedhd gravatar image

You would need to write setup.py and include catkin_python_setup() in CMakeLists as described in Section 1.2 here. This would add your packages to PYTHONPATH when you source the workspace.

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-08-09 02:51:27 -0500

Seen: 555 times

Last updated: Aug 09 '17