导入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 issue page上看到。建议的修复只是评论/usr/local/lib/python3.6/site-packages/ethereum/utils.py
中的第103行
如果出现由版本差异引起的更多错误,切换到使用python2的模块可能是一个好主意。