无法在Python中导入RRDtool
我正在尝试将 RRDtool 导入 Python,因为我想使用 Python 访问 RRD 数据库,但是当我正在尝试导入rrdtool
我收到以下错误。
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
我的 RRDtool 位于 /opt/rrdtool-1.4.5/bin
中。
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
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
好了,只要执行下面的命令,问题就解决了。
Well, the problem is solved just by executing the following command.
您可能需要 py-rrdtool,您可以直接从站点或包管理器获取它。
You probably need py-rrdtool, which you could get directly from the site or your package manager.
Python 模块不太可能位于“bin”文件夹内。从某些配置的路径导入文件要求引用的路径是正确的Python包。这意味着它必须包含一个
__init__.py
文件。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.您可以使用 RRDtool 文档来获取灵感 (
man rrdpyton
)。某物的思路。
沿着应该可以解决问题
You could use the RRDtool documentation for inspiration (
man rrdpyton
). Somethingalong the lines of
should do the trick.