解决“bipwallet\wallet.py decoding str is not supported“问题

    当使用Python来生成ETH或BTC的助记词时,需要安装bipwallet依赖包,如下:

pip install bipwallet==1.0.1

    使用ethCreate.py脚本,来生成助记词、public key、private key。
    //ethCreate.py


from bipwallet import wallet

# generate 12 word mnemonic seed
seed = wallet.generate_mnemonic()

# create bitcoin wallet
##w = wallet.create_wallet(network="BTC", seed=seed, children=1)
w = wallet.create_wallet(network="ETH", seed=seed, children=1)


print(w)

    运行命令: python ethCreate.py
    弹出如下错误:


图(1) wallet.py报“decoding str is not supported”错误

    出现该问题的原因是,当前系统的编码与Python的编译不一致,导致str无法解码,可以删除str(A,encoding=“uft-8”)里的encoding参数,让Python自由解码。步骤如下:

    1) 对于 bipwallet v1.01以下的版本,需要用打开C:\Python38\Lib\site-packages\bipwallet\wallet.py文件,
    按Ctrl+H,
    把str()语句里的第二个参数,encoding="utf-8"全部替换为空,也就是采用系统默认的编码。

图(2) 去掉str()语句里的encoding=“utf-8”参数

    2)对于bipwallet v1.0.2 以上的版本,,则需要先卸载,然后修改wallet.py源码,再用setup.py安装。步骤如下:
    2.1)卸载bipwallet v1.0.2

pip uninstall bipwallet

    2.2)下载bipwallet v1.0.2.rar源码包
    阿里镜像:bipwall v1.0.2.rar
    官网镜像:bipwall v1.0.2.rar

    2.3)解压bipwallet v1.0.2.rar,打开里面bipwallet\wallet.py文件,然后,将里面的把str()语句里的第二个参数,encoding="utf-8"全部替换为空,

    2.4)在bipwallet目录里,使用它自带setup.py脚本安装即可

python setup.py install

猜你喜欢

转载自blog.csdn.net/sanqima/article/details/109749395
str
今日推荐