win系统使用pipenv install时编码问题:
Failed creating virtual environment
[pipenv.exceptions.VirtualenvCreationException]: File "e:\pythontools\anaconda3\lib\site-packages\pipenv\cli\command.py", line 254, in install
[pipenv.exceptions.VirtualenvCreationException]: editable_packages=state.installstate.editables,
[pipenv.exceptions.VirtualenvCreationException]: File "e:\pythontools\anaconda3\lib\site-packages\pipenv\core.py", line 1741, in do_install
[pipenv.exceptions.VirtualenvCreationException]: pypi_mirror=pypi_mirror,
[pipenv.exceptions.VirtualenvCreationException]: File "e:\pythontools\anaconda3\lib\site-packages\pipenv\core.py", line 574, in ensure_project
[pipenv.exceptions.VirtualenvCreationException]: pypi_mirror=pypi_mirror,
[pipenv.exceptions.VirtualenvCreationException]: File "e:\pythontools\anaconda3\lib\site-packages\pipenv\core.py", line 506, in ensure_virtualenv
[pipenv.exceptions.VirtualenvCreationException]: python=python, site_packages=site_packages, pypi_mirror=pypi_mirror
[pipenv.exceptions.VirtualenvCreationException]: File "e:\pythontools\anaconda3\lib\site-packages\pipenv\core.py", line 935, in do_create_virtualenv
[pipenv.exceptions.VirtualenvCreationException]: extra=[crayons.blue("{0}".format(c.err)),]
[pipenv.exceptions.VirtualenvCreationException]: Traceback (most recent call last):
File "e:\pythontools\anaconda3\lib\site-packages\virtualenv.py", line 939, in call_subprocess
line = line.decode(encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb2 in position 38: invalid start byte
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "e:\pythontools\anaconda3\lib\site-packages\virtualenv.py", line 2632, in
main()
File "e:\pythontools\anaconda3\lib\site-packages\virtualenv.py", line 870, in main
symlink=options.symlink,
File "e:\pythontools\anaconda3\lib\site-packages\virtualenv.py", line 1173, in create_environment
install_wheel(to_install, py_executable, search_dirs, download=download)
File "e:\pythontools\anaconda3\lib\site-packages\virtualenv.py", line 1019, in install_wheel
_install_wheel_with_search_dir(download, project_names, py_executable, search_dirs)
File "e:\pythontools\anaconda3\lib\site-packages\virtualenv.py", line 1110, in _install_wheel_with_search_dir
call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=script)
File "e:\pythontools\anaconda3\lib\site-packages\virtualenv.py", line 941, in call_subprocess
line = line.decode(fs_encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb2 in position 38: invalid start byte
Failed to create virtual environment.
解决方案:
找到报错位置\virtualenv.py:将
line = line.decode(fs_encoding)
改为:
line = line.decode('gbk')
原因为:windows默认GBK编码,所以报错
解决成功: