2

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Hunt
  • 8,215
  • 28
  • 116
  • 256

4 Answers4

2

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

sudo apt-get install python-rrd

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Hunt
  • 8,215
  • 28
  • 116
  • 256
0

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
0

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

Jeff
  • 1,807
  • 1
  • 15
  • 17
  • i have created a directory under /opt/rrdtool-1.4.5/lib/ and name of the dir is python2.6/ and inside that i have these files __init__.py Makefile MANIFEST.in README.txt setup.py and now i have set the path as sys.path.append('/opt/rrdtool-1.4.5/lib/python2.6/') but still getting the same error – Hunt Mar 01 '11 at 15:06
0

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Tobi Oetiker
  • 5,167
  • 2
  • 17
  • 23