1、在windows 10 下使用 pip 3 执行
pip install pathos
报错
Exception:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\compat\__init__.py", line 73, in console_to_str
return s.decode(sys.__stdout__.encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xce in position 68: invalid continuation byteDuring handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\commands\install.py", line 342, in run
prefix=options.prefix_path,
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\req\req_set.py", line 784, in install
**kwargs
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\req\req_install.py", line 878, in install
spinner=spinner,
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\utils\__init__.py", line 676, in call_subprocess
line = console_to_str(proc.stdout.readline())
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\compat\__init__.py", line 75, in console_to_str
return s.decode('utf_8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xce in position 68: invalid continuation byteDuring handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\commands\install.py", line 385, in run
requirement_set.cleanup_files()
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\req\req_set.py", line 729, in cleanup_files
req.remove_temporary_source()
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\req\req_install.py", line 977, in remove_temporary_source
rmtree(self.source_dir)
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_vendor\retrying.py", line 49, in wrapped_f
return Retrying(*dargs, **dkw).call(f, *args, **kw)
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_vendor\retrying.py", line 212, in call
raise attempt.get()
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_vendor\retrying.py", line 247, in get
six.reraise(self.value[0], self.value[1], self.value[2])
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_vendor\six.py", line 686, in reraise
raise value
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_vendor\retrying.py", line 200, in call
attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\utils\__init__.py", line 102, in rmtree
οnerrοr=rmtree_errorhandler)
File "C:\ProgramData\Anaconda3\lib\shutil.py", line 494, in rmtree
return _rmtree_unsafe(path, onerror)
File "C:\ProgramData\Anaconda3\lib\shutil.py", line 393, in _rmtree_unsafe
onerror(os.rmdir, path, sys.exc_info())
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\utils\__init__.py", line 114, in rmtree_errorhandler
func(path)
PermissionError: [WinError 32] 另一个程序正在使用此文件,进程无法访问。: 'C:\\Users\\CSJUNJ~1\\AppData\\Local\\Temp\\pip-build-in571x9l\\multiprocess'During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\commands\install.py", line 385, in run
requirement_set.cleanup_files()
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\utils\build.py", line 38, in __exit__
self.cleanup()
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\utils\build.py", line 42, in cleanup
rmtree(self.name)
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_vendor\retrying.py", line 49, in wrapped_f
return Retrying(*dargs, **dkw).call(f, *args, **kw)
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_vendor\retrying.py", line 212, in call
raise attempt.get()
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_vendor\retrying.py", line 247, in get
six.reraise(self.value[0], self.value[1], self.value[2])
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_vendor\six.py", line 686, in reraise
raise value
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_vendor\retrying.py", line 200, in call
attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\utils\__init__.py", line 102, in rmtree
οnerrοr=rmtree_errorhandler)
File "C:\ProgramData\Anaconda3\lib\shutil.py", line 494, in rmtree
return _rmtree_unsafe(path, onerror)
File "C:\ProgramData\Anaconda3\lib\shutil.py", line 384, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:\ProgramData\Anaconda3\lib\shutil.py", line 393, in _rmtree_unsafe
onerror(os.rmdir, path, sys.exc_info())
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\utils\__init__.py", line 114, in rmtree_errorhandler
func(path)
PermissionError: [WinError 32] 另一个程序正在使用此文件,进程无法访问。: 'C:\\Users\\CSJUNJ~1\\AppData\\Local\\Temp\\pip-build-in571x9l\\multiprocess'
参考:https://blog.csdn.net/qq_33530388/article/details/68933201后
修改C:\ProgramData\Anaconda3\Lib\site-packages\pip\compat\__init__.py 第75行
将 return s.decode('utf_8') 改为 return s.decode('cp936')
原因:
编码问题,虽然py3统一用utf-8了。但win下的终端显示用的还是gbk编码。
CP936其实就是GBK,IBM在发明Code Page的时候将GBK放在第936页,所以叫CP936。