0
$\begingroup$

Rosanswers logo

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


Originally posted by apanda on ROS Answers with karma: 1 on 2017-08-09

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by naveedhd with karma: 161 on 2017-08-09

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.