【一】环境
我的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
折腾一下午了,很纠结,请教!