Unable to import RRDtool in Python

9.8k views Asked by At

I am trying to import RRDtool into Python as I want to access an RRD database using Python, but when I am trying to import rrdtool I am getting the following error.

Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path.append('/opt/rrdtool-1.4.5/bin')
>>> import rrdtool
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named rrdtool

My RRDtool is located in /opt/rrdtool-1.4.5/bin.

4

There are 4 answers

0
Hunt On BEST ANSWER

Well, the problem is solved just by executing the following command.

sudo apt-get install python-rrd

1
AudioBubble On

It is unlikely that Python modules are located inside a 'bin' folder. And importing files from some configured path requires that the referred path is a proper Python package. It means it must contain an __init__.py file.

1
Jeff On

You probably need py-rrdtool, which you could get directly from the site or your package manager.

0
Tobi Oetiker On

You could use the RRDtool documentation for inspiration (man rrdpyton). Something along the lines of

import sys
sys.path.append('/path/to/rrdtool/lib/python2.6/site-packages/')
import rrdtool

should do the trick.