开发者

Unable to import RRDtool in Python

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.
>开发者_C百科;>> 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.


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

sudo apt-get install python-rrd


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


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜