oldbee0925 2022-08-05 17:25 采纳率: 91.4%
浏览 82
已结题

python 3.8安装第三方包(pip install)报 unicodedecodeerror错误,请教!

【一】环境
我的python环境是anacoda1.10,python 3.8。安装在windows server 2008 R2服务器上。
【二】故障
在使用pip install -r 命令安装本地包时,先报错:
UnicodeDecodeError: 'gbk' codec can't decode byte 0xda in position 18: illegal multibyte sequence
网上百度,将系统变量PYTHONUTF值设为1,重启,不同内容的报错:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf5 in position 15: invalid start byte
2次报错都指向同一个文件:encoding.py。

#第一次 
C:\Users\Administrator>pip install -r F:\mypython\package\PyMySQL-1.0.2-py3-none-any.whl
ERROR: Exception:
Traceback (most recent call last):
  File "e:\Anaconda3\lib\site-packages\pip\_internal\cli\base_command.py", line228, in _main    status = self.run(options, args)
  File "e:\Anaconda3\lib\site-packages\pip\_internal\cli\req_command.py", line 182, in wrapper    return func(self, options, args)
  File "e:\Anaconda3\lib\site-packages\pip\_internal\commands\install.py", line294, in run
    reqs = self.get_requirements(args, options, finder, session)
  File "e:\Anaconda3\lib\site-packages\pip\_internal\cli\req_command.py", line 334, in get_requirements
    for parsed_req in parse_requirements(
  File "e:\Anaconda3\lib\site-packages\pip\_internal\req\req_file.py", line 150, in parse_requirements
    for parsed_line in parser.parse(filename, constraint):
  File "e:\Anaconda3\lib\site-packages\pip\_internal\req\req_file.py", line 338, in parse
    for line in self._parse_and_recurse(filename, constraint):
  File "e:\Anaconda3\lib\site-packages\pip\_internal\req\req_file.py", line 343, in _parse_and_recurse
    for line in self._parse_file(filename, constraint):
  File "e:\Anaconda3\lib\site-packages\pip\_internal\req\req_file.py", line 376, in _parse_file_, content = get_file_content(
  File "e:\Anaconda3\lib\site-packages\pip\_internal\req\req_file.py", line 584, in get_file_content    content = auto_decode(f.read())
  File "e:\Anaconda3\lib\site-packages\pip\_internal\utils\encoding.py", line 39, in auto_decode
    return data.decode(
UnicodeDecodeError: 'gbk' codec can't decode byte 0xda in position 18: illegal multibyte sequence

#第二次
C:\Users\Administrator>pip install -r F:\mypython\package\PyMySQL-1.0.2-py3-none-any.whl
ERROR: Exception:
Traceback (most recent call last):
  File "e:\Anaconda3\lib\site-packages\pip\_internal\cli\base_command.py", line 228, in _main    status = self.run(options, args)
  File "e:\Anaconda3\lib\site-packages\pip\_internal\cli\req_command.py", line 182, in wrapper     return func(self, options, args)
  File "e:\Anaconda3\lib\site-packages\pip\_internal\commands\install.py", line294, in run  reqs = self.get_requirements(args, options, finder, session)
  File "e:\Anaconda3\lib\site-packages\pip\_internal\cli\req_command.py", line 334, in get_requirements
    for parsed_req in parse_requirements(
  File "e:\Anaconda3\lib\site-packages\pip\_internal\req\req_file.py", line 150, in parse_requirements    for parsed_line in parser.parse(filename, constraint):
  File "e:\Anaconda3\lib\site-packages\pip\_internal\req\req_file.py", line 338, in parse
    for line in self._parse_and_recurse(filename, constraint):
  File "e:\Anaconda3\lib\site-packages\pip\_internal\req\req_file.py", line 343, in _parse_and_recurse
    for line in self._parse_file(filename, constraint):
  File "e:\Anaconda3\lib\site-packages\pip\_internal\req\req_file.py", line 376, in _parse_file_, content = get_file_content(
  File "e:\Anaconda3\lib\site-packages\pip\_internal\req\req_file.py", line 584, in get_file_content    content = auto_decode(f.read())
  File "e:\Anaconda3\lib\site-packages\pip\_internal\utils\encoding.py", line 39, in auto_decode
    return data.decode(
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf5 in position 15: invalid start byte

折腾一下午了,很纠结,请教!

  • 写回答

1条回答 默认 最新

  • 快乐小土狗 2022-08-06 13:43
    关注

    把你的-r去掉

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 8月16日
  • 已采纳回答 8月8日
  • 创建了问题 8月5日

悬赏问题

  • ¥15 PointNet++的onnx模型只能使用一次
  • ¥20 西南科技大学数字信号处理
  • ¥15 有两个非常“自以为是”烦人的问题急期待大家解决!
  • ¥30 STM32 INMP441无法读取数据
  • ¥15 R语言绘制密度图,一个密度曲线内fill不同颜色如何实现
  • ¥100 求汇川机器人IRCB300控制器和示教器同版本升级固件文件升级包
  • ¥15 用visualstudio2022创建vue项目后无法启动
  • ¥15 x趋于0时tanx-sinx极限可以拆开算吗
  • ¥500 把面具戴到人脸上,请大家贡献智慧,别用大模型回答,大模型的答案没啥用
  • ¥15 任意一个散点图自己下载其js脚本文件并做成独立的案例页面,不要作在线的,要离线状态。