# Revision history [back]

### How do I install a Python module with a different name than the catkin package?

My package is named camera_info_manager_py, but the Python module is camera_info_manager.

With rosbuild that was easy: just create a src/camera_info_manager.py script, and dependent packages could import it directly.

With catkin I can't figure out how to make it work. For API compatibility with earlier releases, I prefer not to rename the module camera_info_manager_py (which does work).

I suppose I could add that module to the camera_info_manager package, and make camera_info_manager_py depend on it for compatibility. But, that would be a hassle, and not relevant to the many users of the C++ camera_info_manager package.

### How do I install a Python module with a different name than the catkin package?

My package is named camera_info_manager_py, but the Python module is camera_info_manager.

With rosbuild that was easy: just create a src/camera_info_manager.py script, and dependent packages could import it directly.

With catkin I can't figure out how to make it work. For API compatibility with earlier releases, I prefer not to rename the module camera_info_manager_py (which does work).

I suppose I could add that module to the camera_info_manager package, and make camera_info_manager_py depend on it for compatibility. But, that would be a hassle, and not relevant to the many users of the C++ camera_info_manager package.

EDIT: Thanks, William. I had tried the py_modules, and as you noted, it did not work. I didn't realize that was caused by a missing feature.

I still do not fully understand your recommended work-around. Would the script go in src/camera_info_manager.py, as it did before? I was not able to figure out how to resolve that in the PYTHONPATH.

For compatibility, other packages need to do this:

import camera_info_manager
cinfo = camera_info_manager.CameraInfoManager()


or:

from camera_info_manager import *
cinfo = CameraInfoManager()


I still don't see how to make that happen.

### How do I install a Python module with a different name than the catkin package?

My package is named camera_info_manager_py, but the Python module is camera_info_manager.

With rosbuild that was easy: just create a src/camera_info_manager.py script, and dependent packages could import it directly.

With catkin I can't figure out how to make it work. For API compatibility with earlier releases, I prefer not to rename the module camera_info_manager_py (which does work).

I suppose I could add that module to the camera_info_manager package, and make camera_info_manager_py depend on it for compatibility. But, that would be a hassle, and not relevant to the many users of the C++ camera_info_manager package.

EDIT: Thanks, William. I had tried the py_modules, and as you noted, it did not work. I didn't realize that was caused by a missing feature.

I still do not fully understand your recommended work-around. Would the script go in src/camera_info_manager.py, as it did before? I was not able to figure out how to resolve that in the PYTHONPATH.

For compatibility, other packages need to do this:

import camera_info_manager
cinfo = camera_info_manager.CameraInfoManager()


or:

from camera_info_manager import *
cinfo = CameraInfoManager()


I still don't see how to make that happen.

### How do I install a Python module with a different name than the catkin package?

My package is named camera_info_manager_py, but the Python module is camera_info_manager.

With rosbuild that was easy: just create a src/camera_info_manager.py script, and dependent packages could import it directly.

With catkin I can't figure out how to make it work. For API compatibility with earlier releases, I prefer not to rename the module camera_info_manager_py (which does work).

I suppose I could add that module to the camera_info_manager package, and make camera_info_manager_py depend on it for compatibility. But, that would be a hassle, and not relevant to the many users of the C++ camera_info_manager package.

EDIT: Thanks, William. I had tried the py_modules, and as you noted, it did not work. I didn't realize that was caused by a missing feature.

I do not fully understand your recommended work-around. Would the script go in src/camera_info_manager.py, as it did before? I was not able to figure out how to resolve that in the PYTHONPATH.

For compatibility, other packages need to do this:

import camera_info_manager
cinfo = camera_info_manager.CameraInfoManager()


or:

from camera_info_manager import *
cinfo = CameraInfoManager()


I still don't see how to make that happen.

EDIT2: I did (almost) exactly as you recommended, but catkin installs no camera_info_manager package.

$roscd$ catkin_make
$cd build$ make install
$ls -l ../install/lib/python2.7/dist-packages/ total 20 drwxr-xr-x 3 joq joq 4096 Mar 26 16:59 ackermann_msgs -rw-rw-r-- 1 joq joq 421 Mar 26 16:59 camera_info_manager_py-0.2.0.egg-info drwxrwxr-x 2 joq joq 4096 Mar 26 16:59 unique_id -rw-rw-r-- 1 joq joq 276 Mar 26 16:59 unique_id-1.0.1.egg-info drwxr-xr-x 3 joq joq 4096 Mar 26 16:59 uuid_msgs  So, there is an egg-info for camera_info_manager_py, but no Python package. $ make run_tests_camera_info_manager_py
-- run_tests.py: execute commands
/opt/ros/groovy/bin/rostest --pkgdir=/home/joq/ros/wet/groovy/src/camera_info_manager_py --package=camera_info_manager_py --results-filename tests_unit_test.xml /home/joq/ros/wet/groovy/src/camera_info_manager_py/tests/unit_test.test
... logging to /home/joq/.ros/log/rostest-vision-4-5760.log
[ROSUNIT] Outputting test results to /home/joq/ros/wet/groovy/build/test_results/camera_info_manager_py/rostest-tests_unit_test.xml
Traceback (most recent call last):
File "/home/joq/ros/wet/groovy/src/camera_info_manager_py/tests/test_camera_info_manager.py", line 17, in <module>
from camera_info_manager import *
ImportError: No module named camera_info_manager
testtest_camera_info_manager_py ... FAILURE!


As you can see, the from camera_info_manager import * fails.

### How do I install a Python module with a different name than the catkin package?

My package is named camera_info_manager_py, but the Python module is camera_info_manager.

With rosbuild that was easy: just create a src/camera_info_manager.py script, and dependent packages could import it directly.

With catkin I can't figure out how to make it work. For API compatibility with earlier releases, I prefer not to rename the module camera_info_manager_py (which does work).

I suppose I could add that module to the camera_info_manager package, and make camera_info_manager_py depend on it for compatibility. But, that would be a hassle, and not relevant to the many users of the C++ camera_info_manager package.

EDIT: Thanks, William. I had tried the py_modules, and as you noted, it did not work. I didn't realize that was caused by a missing feature.

I do not fully understand your recommended work-around. Would the script go in src/camera_info_manager.py, as it did before? I was not able to figure out how to resolve that in the PYTHONPATH.

For compatibility, other packages need to do this:

import camera_info_manager
cinfo = camera_info_manager.CameraInfoManager()


or:

from camera_info_manager import *
cinfo = CameraInfoManager()


I still don't see how to make that happen.

EDIT2: I did (almost) exactly as you recommended, but catkin installs no camera_info_manager package.

$roscd$ catkin_make
$cd build$ make install
$ls -l ../install/lib/python2.7/dist-packages/ total 20 drwxr-xr-x 3 joq joq 4096 Mar 26 16:59 ackermann_msgs -rw-rw-r-- 1 joq joq 421 Mar 26 16:59 camera_info_manager_py-0.2.0.egg-info drwxrwxr-x 2 joq joq 4096 Mar 26 16:59 unique_id -rw-rw-r-- 1 joq joq 276 Mar 26 16:59 unique_id-1.0.1.egg-info drwxr-xr-x 3 joq joq 4096 Mar 26 16:59 uuid_msgs  So, there is an egg-info for camera_info_manager_py, but no Python package. $ make run_tests_camera_info_manager_py
-- run_tests.py: execute commands
/opt/ros/groovy/bin/rostest --pkgdir=/home/joq/ros/wet/groovy/src/camera_info_manager_py --package=camera_info_manager_py --results-filename tests_unit_test.xml /home/joq/ros/wet/groovy/src/camera_info_manager_py/tests/unit_test.test
... logging to /home/joq/.ros/log/rostest-vision-4-5760.log
[ROSUNIT] Outputting test results to /home/joq/ros/wet/groovy/build/test_results/camera_info_manager_py/rostest-tests_unit_test.xml
Traceback (most recent call last):
File "/home/joq/ros/wet/groovy/src/camera_info_manager_py/tests/test_camera_info_manager.py", line 17, in <module>
from camera_info_manager import *
ImportError: No module named camera_info_manager
testtest_camera_info_manager_py ... FAILURE!


As you can see, the from camera_info_manager import * fails.

The only difference with what you recommended is that my src/camera_info_manager/__init__.py contains only this:

from .camera_info_manager import *


I did it that way because the camera_info_manager module was already careful not to define anything not needed by its users. I guess it is equivalent to putting the entire script inside __init__.py.

### How do I install a Python module with a different name than the catkin package?

My package is named camera_info_manager_py, but the Python module is camera_info_manager.

With rosbuild that was easy: just create a src/camera_info_manager.py script, and dependent packages could import it directly.

With catkin I can't figure out how to make it work. For API compatibility with earlier releases, I prefer not to rename the module camera_info_manager_py (which does work).

I suppose I could add that module to the camera_info_manager package, and make camera_info_manager_py depend on it for compatibility. But, that would be a hassle, and not relevant to the many users of the C++ camera_info_manager package.

EDIT: Thanks, William. I had tried the py_modules, and as you noted, it did not work. I didn't realize that was caused by a missing feature.

I do not fully understand your recommended work-around. Would the script go in src/camera_info_manager.py, as it did before? I was not able to figure out how to resolve that in the PYTHONPATH.

For compatibility, other packages need to do this:

import camera_info_manager
cinfo = camera_info_manager.CameraInfoManager()


or:

from camera_info_manager import *
cinfo = CameraInfoManager()


I still don't see how to make that happen.

EDIT2: I did (almost) exactly as you recommended, but catkin installs no camera_info_manager package.

$roscd$ catkin_make
$cd build$ make install
$ls -l ../install/lib/python2.7/dist-packages/ total 20 drwxr-xr-x 3 joq joq 4096 Mar 26 16:59 ackermann_msgs -rw-rw-r-- 1 joq joq 421 Mar 26 16:59 camera_info_manager_py-0.2.0.egg-info drwxrwxr-x 2 joq joq 4096 Mar 26 16:59 unique_id -rw-rw-r-- 1 joq joq 276 Mar 26 16:59 unique_id-1.0.1.egg-info drwxr-xr-x 3 joq joq 4096 Mar 26 16:59 uuid_msgs  So, there is an egg-info for camera_info_manager_py, but no Python package. $ make run_tests_camera_info_manager_py
-- run_tests.py: execute commands
/opt/ros/groovy/bin/rostest --pkgdir=/home/joq/ros/wet/groovy/src/camera_info_manager_py --package=camera_info_manager_py --results-filename tests_unit_test.xml /home/joq/ros/wet/groovy/src/camera_info_manager_py/tests/unit_test.test
... logging to /home/joq/.ros/log/rostest-vision-4-5760.log
[ROSUNIT] Outputting test results to /home/joq/ros/wet/groovy/build/test_results/camera_info_manager_py/rostest-tests_unit_test.xml
Traceback (most recent call last):
File "/home/joq/ros/wet/groovy/src/camera_info_manager_py/tests/test_camera_info_manager.py", line 17, in <module>
from camera_info_manager import *
ImportError: No module named camera_info_manager
testtest_camera_info_manager_py ... FAILURE!


As you can see, the from camera_info_manager import * fails.

The only difference with what you recommended is that my src/camera_info_manager/__init__.py contains only this:

from .camera_info_manager import *


I did it that way because the camera_info_manager module was already careful not to define anything not needed by its users. I guess it is equivalent to putting the entire script inside __init__.py.

EDIT3: here's my current setup.py:

#!/usr/bin/env python

from distutils.core import setup
from catkin_pkg.python_setup import generate_distutils_setup

d = generate_distutils_setup(
py_modules=['camera_info_manager'],
package_dir={'': 'src'},
install_requires=['yaml'],
)

setup(**d)


### How do I install a Python module with a different name than the catkin package?

My package is named camera_info_manager_py, but the Python module is camera_info_manager.

With rosbuild that was easy: just create a src/camera_info_manager.py script, and dependent packages could import it directly.

With catkin I can't figure out how to make it work. For API compatibility with earlier releases, I prefer not to rename the module camera_info_manager_py (which does work).

I suppose I could add that module to the camera_info_manager package, and make camera_info_manager_py depend on it for compatibility. But, that would be a hassle, and not relevant to the many users of the C++ camera_info_manager package.

EDIT: Thanks, William. I had tried the py_modules, and as you noted, it did not work. I didn't realize that was caused by a missing feature.

I do not fully understand your recommended work-around. Would the script go in src/camera_info_manager.py, as it did before? I was not able to figure out how to resolve that in the PYTHONPATH.

For compatibility, other packages need to do this:

import camera_info_manager
cinfo = camera_info_manager.CameraInfoManager()


or:

from camera_info_manager import *
cinfo = CameraInfoManager()


I still don't see how to make that happen.

EDIT2: I did (almost) exactly as you recommended, but catkin installs no camera_info_manager package.

$roscd$ catkin_make
$cd build$ make install
$ls -l ../install/lib/python2.7/dist-packages/ total 20 drwxr-xr-x 3 joq joq 4096 Mar 26 16:59 ackermann_msgs -rw-rw-r-- 1 joq joq 421 Mar 26 16:59 camera_info_manager_py-0.2.0.egg-info drwxrwxr-x 2 joq joq 4096 Mar 26 16:59 unique_id -rw-rw-r-- 1 joq joq 276 Mar 26 16:59 unique_id-1.0.1.egg-info drwxr-xr-x 3 joq joq 4096 Mar 26 16:59 uuid_msgs  So, there is an egg-info for camera_info_manager_py, but no Python package. $ make run_tests_camera_info_manager_py
-- run_tests.py: execute commands
/opt/ros/groovy/bin/rostest --pkgdir=/home/joq/ros/wet/groovy/src/camera_info_manager_py --package=camera_info_manager_py --results-filename tests_unit_test.xml /home/joq/ros/wet/groovy/src/camera_info_manager_py/tests/unit_test.test
... logging to /home/joq/.ros/log/rostest-vision-4-5760.log
[ROSUNIT] Outputting test results to /home/joq/ros/wet/groovy/build/test_results/camera_info_manager_py/rostest-tests_unit_test.xml
Traceback (most recent call last):
File "/home/joq/ros/wet/groovy/src/camera_info_manager_py/tests/test_camera_info_manager.py", line 17, in <module>
from camera_info_manager import *
ImportError: No module named camera_info_manager
testtest_camera_info_manager_py ... FAILURE!


As you can see, the from camera_info_manager import * fails.

The only difference with what you recommended is that my src/camera_info_manager/__init__.py contains only this:

from .camera_info_manager import *


I did it that way because the camera_info_manager module was already careful not to define anything not needed by its users. I guess it is equivalent to putting the entire script inside __init__.py.

EDIT3: here's my current setup.py:

#!/usr/bin/env python

from distutils.core import setup
from catkin_pkg.python_setup import generate_distutils_setup

d = generate_distutils_setup(
py_modules=['camera_info_manager'],
package_dir={'': 'src'},
install_requires=['yaml'],
)

setup(**d)


EDIT4: yes, the install did show these errors:

+ cd /home/joq/ros/wet/groovy/src/camera_info_manager_py
+ /usr/bin/env PYTHONPATH=/home/joq/ros/wet/groovy/install/lib/python2.7/dist-packages:/home/joq/ros/wet/groovy/build/lib/python2.7/dist-packages:/home/joq/ros/wet/groovy/devel/lib/python2.7/dist-packages:/opt/ros/groovy/lib/python2.7/dist-packages CATKIN_BINARY_DIR=/home/joq/ros/wet/groovy/build /usr/bin/python /home/joq/ros/wet/groovy/src/camera_info_manager_py/setup.py build --build-base /home/joq/ros/wet/groovy/build/camera_info_manager_py install --install-layout=deb --prefix=/home/joq/ros/wet/groovy/install --install-scripts=/home/joq/ros/wet/groovy/install/bin
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'install_requires'
warnings.warn(msg)
running build
running build_py
running install
running install_lib
warning: install_lib: '/home/joq/ros/wet/groovy/build/camera_info_manager_py/lib.linux-x86_64-2.7' does not exist -- no Python modules to install

 8 retagged

### How do I install a Python module with a different name than the catkin package?

My package is named camera_info_manager_py, but the Python module is camera_info_manager.

With rosbuild that was easy: just create a src/camera_info_manager.py script, and dependent packages could import it directly.

With catkin I can't figure out how to make it work. For API compatibility with earlier releases, I prefer not to rename the module camera_info_manager_py (which does work).

I suppose I could add that module to the camera_info_manager package, and make camera_info_manager_py depend on it for compatibility. But, that would be a hassle, and not relevant to the many users of the C++ camera_info_manager package.

EDIT: Thanks, William. I had tried the py_modules, and as you noted, it did not work. I didn't realize that was caused by a missing feature.

I do not fully understand your recommended work-around. Would the script go in src/camera_info_manager.py, as it did before? I was not able to figure out how to resolve that in the PYTHONPATH.

For compatibility, other packages need to do this:

import camera_info_manager
cinfo = camera_info_manager.CameraInfoManager()


or:

from camera_info_manager import *
cinfo = CameraInfoManager()


I still don't see how to make that happen.

EDIT2: I did (almost) exactly as you recommended, but catkin installs no camera_info_manager package.

$roscd$ catkin_make
$cd build$ make install
$ls -l ../install/lib/python2.7/dist-packages/ total 20 drwxr-xr-x 3 joq joq 4096 Mar 26 16:59 ackermann_msgs -rw-rw-r-- 1 joq joq 421 Mar 26 16:59 camera_info_manager_py-0.2.0.egg-info drwxrwxr-x 2 joq joq 4096 Mar 26 16:59 unique_id -rw-rw-r-- 1 joq joq 276 Mar 26 16:59 unique_id-1.0.1.egg-info drwxr-xr-x 3 joq joq 4096 Mar 26 16:59 uuid_msgs  So, there is an egg-info for camera_info_manager_py, but no Python package. $ make run_tests_camera_info_manager_py
-- run_tests.py: execute commands
/opt/ros/groovy/bin/rostest --pkgdir=/home/joq/ros/wet/groovy/src/camera_info_manager_py --package=camera_info_manager_py --results-filename tests_unit_test.xml /home/joq/ros/wet/groovy/src/camera_info_manager_py/tests/unit_test.test
... logging to /home/joq/.ros/log/rostest-vision-4-5760.log
[ROSUNIT] Outputting test results to /home/joq/ros/wet/groovy/build/test_results/camera_info_manager_py/rostest-tests_unit_test.xml
Traceback (most recent call last):
File "/home/joq/ros/wet/groovy/src/camera_info_manager_py/tests/test_camera_info_manager.py", line 17, in <module>
from camera_info_manager import *
ImportError: No module named camera_info_manager
testtest_camera_info_manager_py ... FAILURE!


As you can see, the from camera_info_manager import * fails.

The only difference with what you recommended is that my src/camera_info_manager/__init__.py contains only this:

from .camera_info_manager import *


I did it that way because the camera_info_manager module was already careful not to define anything not needed by its users. I guess it is equivalent to putting the entire script inside __init__.py.

EDIT3: here's my current setup.py:

#!/usr/bin/env python

from distutils.core import setup
from catkin_pkg.python_setup import generate_distutils_setup

d = generate_distutils_setup(
py_modules=['camera_info_manager'],
package_dir={'': 'src'},
install_requires=['yaml'],
)

setup(**d)


EDIT4: yes, the install did show these errors:

+ cd /home/joq/ros/wet/groovy/src/camera_info_manager_py
+ /usr/bin/env PYTHONPATH=/home/joq/ros/wet/groovy/install/lib/python2.7/dist-packages:/home/joq/ros/wet/groovy/build/lib/python2.7/dist-packages:/home/joq/ros/wet/groovy/devel/lib/python2.7/dist-packages:/opt/ros/groovy/lib/python2.7/dist-packages CATKIN_BINARY_DIR=/home/joq/ros/wet/groovy/build /usr/bin/python /home/joq/ros/wet/groovy/src/camera_info_manager_py/setup.py build --build-base /home/joq/ros/wet/groovy/build/camera_info_manager_py install --install-layout=deb --prefix=/home/joq/ros/wet/groovy/install --install-scripts=/home/joq/ros/wet/groovy/install/bin
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'install_requires'
warnings.warn(msg)
running build
running build_py
running install
running install_lib
warning: install_lib: '/home/joq/ros/wet/groovy/build/camera_info_manager_py/lib.linux-x86_64-2.7' does not exist -- no Python modules to install

 9 retagged

### How do I install a Python module with a different name than the catkin package?

My package is named camera_info_manager_py, but the Python module is camera_info_manager.

With rosbuild that was easy: just create a src/camera_info_manager.py script, and dependent packages could import it directly.

With catkin I can't figure out how to make it work. For API compatibility with earlier releases, I prefer not to rename the module camera_info_manager_py (which does work).

I suppose I could add that module to the camera_info_manager package, and make camera_info_manager_py depend on it for compatibility. But, that would be a hassle, and not relevant to the many users of the C++ camera_info_manager package.

EDIT: Thanks, William. I had tried the py_modules, and as you noted, it did not work. I didn't realize that was caused by a missing feature.

I do not fully understand your recommended work-around. Would the script go in src/camera_info_manager.py, as it did before? I was not able to figure out how to resolve that in the PYTHONPATH.

For compatibility, other packages need to do this:

import camera_info_manager
cinfo = camera_info_manager.CameraInfoManager()


or:

from camera_info_manager import *
cinfo = CameraInfoManager()


I still don't see how to make that happen.

EDIT2: I did (almost) exactly as you recommended, but catkin installs no camera_info_manager package.

$roscd$ catkin_make
$cd build$ make install
$ls -l ../install/lib/python2.7/dist-packages/ total 20 drwxr-xr-x 3 joq joq 4096 Mar 26 16:59 ackermann_msgs -rw-rw-r-- 1 joq joq 421 Mar 26 16:59 camera_info_manager_py-0.2.0.egg-info drwxrwxr-x 2 joq joq 4096 Mar 26 16:59 unique_id -rw-rw-r-- 1 joq joq 276 Mar 26 16:59 unique_id-1.0.1.egg-info drwxr-xr-x 3 joq joq 4096 Mar 26 16:59 uuid_msgs  So, there is an egg-info for camera_info_manager_py, but no Python package. $ make run_tests_camera_info_manager_py
-- run_tests.py: execute commands
/opt/ros/groovy/bin/rostest --pkgdir=/home/joq/ros/wet/groovy/src/camera_info_manager_py --package=camera_info_manager_py --results-filename tests_unit_test.xml /home/joq/ros/wet/groovy/src/camera_info_manager_py/tests/unit_test.test
... logging to /home/joq/.ros/log/rostest-vision-4-5760.log
[ROSUNIT] Outputting test results to /home/joq/ros/wet/groovy/build/test_results/camera_info_manager_py/rostest-tests_unit_test.xml
Traceback (most recent call last):
File "/home/joq/ros/wet/groovy/src/camera_info_manager_py/tests/test_camera_info_manager.py", line 17, in <module>
from camera_info_manager import *
ImportError: No module named camera_info_manager
testtest_camera_info_manager_py ... FAILURE!


As you can see, the from camera_info_manager import * fails.

The only difference with what you recommended is that my src/camera_info_manager/__init__.py contains only this:

from .camera_info_manager import *


I did it that way because the camera_info_manager module was already careful not to define anything not needed by its users. I guess it is equivalent to putting the entire script inside __init__.py.

EDIT3: here's my current setup.py:

#!/usr/bin/env python

from distutils.core import setup
from catkin_pkg.python_setup import generate_distutils_setup

d = generate_distutils_setup(
py_modules=['camera_info_manager'],
package_dir={'': 'src'},
install_requires=['yaml'],
)

setup(**d)


EDIT4: yes, the install did show these errors:

+ cd /home/joq/ros/wet/groovy/src/camera_info_manager_py
+ /usr/bin/env PYTHONPATH=/home/joq/ros/wet/groovy/install/lib/python2.7/dist-packages:/home/joq/ros/wet/groovy/build/lib/python2.7/dist-packages:/home/joq/ros/wet/groovy/devel/lib/python2.7/dist-packages:/opt/ros/groovy/lib/python2.7/dist-packages CATKIN_BINARY_DIR=/home/joq/ros/wet/groovy/build /usr/bin/python /home/joq/ros/wet/groovy/src/camera_info_manager_py/setup.py build --build-base /home/joq/ros/wet/groovy/build/camera_info_manager_py install --install-layout=deb --prefix=/home/joq/ros/wet/groovy/install --install-scripts=/home/joq/ros/wet/groovy/install/bin
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'install_requires'
warnings.warn(msg)
running build
running build_py