无法在 Python 3.6 中导入 ethjsonrpc , ubuntu



导入时ethjsonrpc它抛出如下错误:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/site-packages/ethjsonrpc/__init__.py", line 1, in <module>
from ethjsonrpc.client import (EthJsonRpc, ParityEthJsonRpc,
File "/usr/local/lib/python3.6/site-packages/ethjsonrpc/client.py", line 7, in <module>
from ethereum import utils
File "/usr/local/lib/python3.6/site-packages/ethereum/utils.py", line 103, in <module>
assert sha3('').encode('hex') == 'c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470'
AttributeError: 'bytes' object has no attribute 'encode'

这是ethjsonrpc的问题,可以在github问题页面上看到。建议的解决方法是仅注释第 103 行/usr/local/lib/python3.6/site-packages/ethereum/utils.py

切换到将此模块与 python2 一起使用可能是个好主意,以防出现更多由版本差异引起的错误。

最新更新