Jenkins构建python项目PyMySQL报错: with open(“./README.rst“, encoding=“utf-8“) as f: TypeError: ‘encodi

报错如下:

Collecting PyMySQL>=1.0.0
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/2b/c4/3c3e7e598b1b490a2525068c22f397fda13f48623b7bd54fb209cd0ab774/PyMySQL-1.0.0.tar.gz (45 kB)
    ERROR: Command errored out with exit status 1:
     command: /bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-8fspQ4/pymysql/setup.py'"'"'; __file__='"'"'/tmp/pip-install-8fspQ4/pymysql/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-1YpVoa
         cwd: /tmp/pip-install-8fspQ4/pymysql/
    Complete output (5 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-8fspQ4/pymysql/setup.py", line 6, in <module>
        with open("./README.rst", encoding="utf-8") as f:
    TypeError: 'encoding' is an invalid keyword argument for this function

报错原因:

  • 问题分析:

    • 在安装 PyMySQL 版本 1.0.0 时,出现了错误。
    • 错误提示中显示 TypeError: 'encoding' is an invalid keyword argument for this function,表明使用了无效的关键字参数。

解决办法:

1.去源地址下载pymysql

下载对应版本pymysql

Links for PyMySQL

2.复制下载包到任意文件夹

(1)解压下载包

(2)找到setup.py文件编辑

把with open("./README.rst", encoding="utf-8") as f:

替换成:with open("./README.rst",) as f:

原:

编辑后:

3.将编辑后整个解压文件打包 放到python项目里

并修改executor.sh命令

  • 5
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

海是倒过来的天~

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值