Hello guys,
I have a question about importing my own python modules from a package I wrote.
I am using ROS Indigo on Ubuntu 14.04.
According to
Assuming I have a package called mape_misc under catkin_ws/src,
the structure of it is :
src/mape_misc/
├── CMakeLists.txt
├── package.xml
├── setup.py
└── src
└── mape_misc
├── __init__.py
├── MAPEopcode.py
I wanted to import mape_misc.MAPEopcode in another python packages. Supposing there is a class OPCODE
in MAPEopcode.py
However, in the other package, I got
from mape_misc.MAPEopcode import OPCODE
ImportError: No module named mape_misc.MAPEopcode
I'm stuck here right now, the content of my setup.py is :
#!/usr/bin/env python
from distutils.core import setup
from catkin_pkg.python_setup import generate_distutils_setup
setup_args = generate_distutils_setup(
package=['mape_misc'],
package_dir={'': 'src'},
)
setup(**setup_args)
In mape_misc
, CMakeLists.txt
is:
cmake_minimum_required(VERSION 2.8.3)
project(mape_misc)
find_package(catkin REQUIRED COMPONENTS
rospy
)
catkin_python_setup()
catkin_package(
CATKIN_DEPENDS rospy
)
I don't think I need to have a install()
because I just want to use modules.
In MAPEopcode I just defined a Enum.
I've tried to clean the build and redo catkin_make, but still no luck.
Thanks for any advice!
Edit 1: I thought for any correct import, catkin_ws/src/mape_misc/src
should be in PYTHONPATH
. However, after I built everything and source devel/setup.bash
, echo $PYTHONPATH
showed only:
/home/xbot/catkin_ws/devel/lib/python2.7/dist-packages:/opt/ros/indigo/lib/python2.7/dist-packages:/home/xbot/.local/lib/python2.7/site-packages:/usr/local/lib/python2.7/dist-packages
Originally posted by mutantRobot on ROS Answers with karma: 21 on 2017-08-28
Post score: 0