报错如下:
pip3 install -r requirements.txt
ERROR: Exception:
Traceback (most recent call last):
File "d:\ProgramData\Anaconda3\envs\langchain-chatglm\lib\site-packages\pip\_internal\cli\base_command.py", line 169, in exc_logging_wrapper
status = run_func(*args)
File "d:\ProgramData\Anaconda3\envs\langchain-chatglm\lib\site-packages\pip\_internal\cli\req_command.py", line 248, in wrapper
return func(self, options, args)
File "d:\ProgramData\Anaconda3\envs\langchain-chatglm\lib\site-packages\pip\_internal\commands\install.py", line 342, in run
reqs = self.get_requirements(args, options, finder, session)
File "d:\ProgramData\Anaconda3\envs\langchain-chatglm\lib\site-packages\pip\_internal\cli\req_command.py", line 433, in get_requirements
for parsed_req in parse_requirements(
File "d:\ProgramData\Anaconda3\envs\langchain-chatglm\lib\site-packages\pip\_internal\req\req_file.py", line 148, in parse_requirements
解决办法:
Python 的 open 方法默认编码取决于平台,如果是 Windows 平台,默认编码是 gbk,如果文件是 utf-8 编码,就会报这个错误。
把文件保存为ansi码即可。