pip 安装报gbk编码错误

1.错误报错

long_description = readme.read()
    UnicodeDecodeError: 'gbk' codec can't decode byte 0xad in position 167: illegal multibyte sequence
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

去下载源包

例如 用迅雷下载 https://pypi.tuna.tsinghua.edu.cn/packages/03/c0/3c16026f07a09949618067a5f14e133053933ae4942fb06883fc9b68fe83/django-mdeditor-0.1.17.tar.gz

  1. 解压缩
  2. 改文件 修改setup.py文件

把如下代码修改

with open(os.path.join(os.path.dirname(__file__), 'README.md')) as readme:
    long_description = readme.read()

修改成如下:

with open(os.path.join(os.path.dirname(__file__), 'README.md'),mode='r',encoding='UTF-8') as readme:
    long_description = readme.read()
  1. 压缩整个文件夹,改后缀名为 tar.gz
  2. pip install 安装

例如 pip install django-mdeditor-0.1.17.tar.gz