ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

ImportError: No module named _roslz4 after Installing from source

asked 2014-11-12 06:17:48 -0500

arp gravatar image

updated 2021-12-03 09:50:52 -0500

Evgeny gravatar image


I am trying to install ros on a slackware based distribution. I am following the instructions given on this page

I am trying to do a staged installation. i.e. first I install in a temporary directory temp/opt/ros/indigo and then copy the resulting temp/opt/ros/indigo/ folder to the /opt/ros/indigo folder. I am able to compile ros without problems.

I source the setup.bash file from /opt/ros/indigo/ after that.

roscore also runs fine.

But when I run rostopic

I get the Error.

Traceback (most recent call last):
  File "/opt/ros/indigo/bin/rostopic", line 35, in <module>
  File "/opt/ros/indigo/lib64/python2.7/site-packages/rostopic/", line 1752, in rostopicmain
    import rosbag
  File "/opt/ros/indigo/lib64/python2.7/site-packages/rosbag/", line 33, in <module>
    from .bag import Bag, Compression, ROSBagException, ROSBagFormatException, ROSBagUnindexedException
  File "/opt/ros/indigo/lib64/python2.7/site-packages/rosbag/", line 64, in <module>
    import roslz4
  File "/opt/ros/indigo/lib64/python2.7/site-packages/roslz4/", line 33, in <module>
    from _roslz4 import *
ImportError: No module named _roslz4

All other commands seem to have no problems. But the ros-commands where _roslz4 is imported the above error comes up.

edit retag flag offensive close merge delete


Seems like you don't have rosbag compiled with lz4 support, but it might also be related to the fact that you are relocating the result before using it. Can you source the setup file in the temp directory and see if you have the same problem?

William gravatar image William  ( 2014-11-12 20:23:24 -0500 )edit

I sourced the setup.bash from the install_isolated directory and I still face the same problem. About compiling I didn't get any errors. When I source the /opt/ros/indigo/setup.bash file, isn't it supposed to set the env variables appropriately?

arp gravatar image arp  ( 2014-11-13 01:34:21 -0500 )edit

If you get the same problem from the install_isolated directory then maybe it is passing silently even though it did not find lz4 at build time. Look at the build logs for rosbag and rosbag_storage.

William gravatar image William  ( 2014-11-13 02:18:25 -0500 )edit

The problem seems occur only for indigo. I installed hydro. After sourcing hydro's setup.bash rostopic doesn't complain about _roslz4. I checked the CMakeOutput.log for indigo installation in the build_isolated directory. At the end it check for this function BZ2_bzCompressInit. Is it for lz4??

arp gravatar image arp  ( 2014-11-13 04:38:59 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2014-11-13 11:59:51 -0500

Dirk Thomas gravatar image

It looks like that on your slackware based distribution the folder structure is different then on Ubuntu. On Ubuntu the shared library is place in the following location:


Since you system uses lib64 it will likely not have the right paths set. Can you please check where the shared library is for you?

If you modify your environment variable accordingly it should be able to import the shared library correctly. May this needs modification to work well out-of-box on you distribution. Please consider providing a pull request if you can figure out how you distro is different the Ubuntu.

Since the lz4 compression is a new feature of ros bags in Indigo it does work for you in Hydro.

edit flag offensive delete link more


The is located at:


When I source <prefix>/setup.bash the above path is correctly added to PYTHONPATH. But rostopic does not find it and I get ImportError.

arp gravatar image arp  ( 2014-11-14 01:56:54 -0500 )edit

Ok. I got it working by moving the shared library to <prefix>/lib64/python2.7/site-packages/ roslz4/. I was wondering shouldn't python look for for once <prefix>/lib/python2.7/site-packages is on the PYTHONPATH??

arp gravatar image arp  ( 2014-11-14 04:45:50 -0500 )edit

Should I convert the above as answer? I have still not figured out how to make it work by just adjusting the PYTHONPATH. It works though, just by moving the shared library.

arp gravatar image arp  ( 2014-11-17 01:22:57 -0500 )edit

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


Asked: 2014-11-12 06:17:48 -0500

Seen: 1,840 times

Last updated: Nov 13 '14