【问题标题】:Can't import merkletools library in Python无法在 Python 中导入 merkletools 库
【发布时间】:2018-10-30 12:12:33
【问题描述】:

我将成功执行的 merkletools 操作保存在普通 python 脚本中。但是在处理 CGI 脚本时,我无法使用 from merkletools import MerkleTools 导入 merkletools 库。有什么解决办法吗?

我正在使用 apache2 服务器。 apache2错误日志如下

    [Tue Oct 30 17:16:13.309058 2018] [cgi:error] [pid 23964:tid 139710529734400] [client 192.168.2.91:51042] AH01215: Traceback (most recent call last):: /var/www/cgi-bin/file.py, referer: http://192.168.2.91/
    [Tue Oct 30 17:16:13.309199 2018] [cgi:error] [pid 23964:tid 139710529734400] [client 192.168.2.91:51042] AH01215:   File "/var/www/cgi-bin/file.py", line 2, in <module>: /var/www/cgi-bin/file.py, referer: http://192.168.2.91/
    [Tue Oct 30 17:16:13.309254 2018] [cgi:error] [pid 23964:tid 139710529734400] [client 192.168.2.91:51042] AH01215:     : /var/www/cgi-bin/file.py, referer: http://192.168.2.91/
    [Tue Oct 30 17:16:13.309299 2018] [cgi:error] [pid 23964:tid 139710529734400] [client 192.168.2.91:51042] AH01215: from merkletools import MerkleTools: /var/www/cgi-bin/file.py, referer: http://192.168.2.91/
    [Tue Oct 30 17:16:13.309345 2018] [cgi:error] [pid 23964:tid 139710529734400] [client 192.168.2.91:51042] AH01215: ImportError: /var/www/cgi-bin/file.py, referer: http://192.168.2.91/
    [Tue Oct 30 17:16:13.309386 2018] [cgi:error] [pid 23964:tid 139710529734400] [client 192.168.2.91:51042] AH01215: : : /var/www/cgi-bin/file.py, referer: http://192.168.2.91/
    [Tue Oct 30 17:16:13.309428 2018] [cgi:error] [pid 23964:tid 139710529734400] [client 192.168.2.91:51042] AH01215: No module named merkletools: /var/www/cgi-bin/file.py, referer: http://192.168.2.91/
    [Tue Oct 30 17:16:13.309449 2018] [cgi:error] [pid 23964:tid 139710529734400] [client 192.168.2.91:51042] AH01215: : /var/www/cgi-bin/file.py, referer: http://192.168.2.91/
    [Tue Oct 30 17:16:13.311719 2018] [cgi:error] [pid 23964:tid 139710529734400] [client 192.168.2.91:51042] End of script output before headers: file.py, referer: http://192.168.2.91/

【问题讨论】:

    标签: python python-3.x apache cgi


    【解决方案1】:

    请参考此链接 - 1.https://github.com/Tierion/pymerkletools 2.https://github.com/tierion/merkle-tools

    还要检查您的 python 版本及其依赖项。

    【讨论】:

    • 我已经学习了这些存储库。我的问题是导入模块。如果我的 python 代码在根文件夹中,有什么需要注意的吗?
    • 需要查看更多详细信息。如果您可以共享一些与您在环境中执行的相同和更多详细信息相关的日志文件,那就太好了。
    • 我已经解决了这个问题。问题是 apache 无法读取 merkletools 模块,因为它以不同的用户身份运行。我在全球范围内安装了 merkletools 库。现在它运行正常。您的支持对我来说意义重大。谢谢
    • 很高兴您发现它很有用。 :)
    猜你喜欢
    • 2018-11-30
    • 2020-12-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-11
    • 1970-01-01
    • 1970-01-01
    • 2021-09-08
    相关资源
    最近更新 更多