使用pipenv -h,UnicodeDecodeError:'utf-8'

时间:2018-11-24 03:39:19

标签: python pipenv

使用pipenv -h和其他命令--venv -install,UnicodeDecodeError:'utf-8',pipenv命令出错,而我在其他地方找不到答案。

F:\proc_py\pipEnv>pipenv -h
Traceback (most recent call last):
  File "e:\python3.6\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "e:\python3.6\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "E:\python3.6\Scripts\pipenv.exe\__main__.py", line 5, in <module>
  File "e:\python3.6\lib\site-packages\pipenv\__init__.py", line 47, in <module>
    from .cli import cli
  File "e:\python3.6\lib\site-packages\pipenv\cli\__init__.py", line 3, in <modu
le>
    from .command import cli
  File "e:\python3.6\lib\site-packages\pipenv\cli\command.py", line 7, in <modul
e>
    import crayons
  File "e:\python3.6\lib\site-packages\pipenv\patched\crayons.py", line 49, in <
module>
    is_powershell = "powershell" in shellingham.detect_shell()[0]
  File "e:\python3.6\lib\site-packages\pipenv\vendor\shellingham\__init__.py", l
ine 22, in detect_shell
    shell = get_shell(pid, max_depth=max_depth)
  File "e:\python3.6\lib\site-packages\pipenv\vendor\shellingham\nt.py", line 10
0, in get_shell
    processes = dict(_iter_process())
  File "e:\python3.6\lib\site-packages\pipenv\vendor\shellingham\nt.py", line 78
, in _iter_process
    info = {'executable': str(pe.szExeFile.decode('utf-8'))}
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xba in position 0: invalid
start byte

我不知道为什么,pipenv命令出错。在其他地方找不到答案。

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题,并且潜伏在互联网上寻求解决方案,但是时间不多,并想出了一些可行的解决方法

我正在尝试通过Pycharm解释器设置来安装PIPEnvironment,并且出现了问题:

Failed creating virtual environment 
[pipenv.exceptions.VirtualenvCreationException]:   File "C:\Users\ogmamedo\AppData\Roaming\Python\Python37\site-packages\pipenv\vendor\click\decorators.py", line 17, in new_func
[pipenv.exceptions.VirtualenvCreationException]:       return f(get_current_context(), *args, **kwargs)
[pipenv.exceptions.VirtualenvCreationException]:   File "C:\Users\ogmamedo\AppData\Roaming\Python\Python37\site-packages\pipenv\cli\command.py", line 208, in cli
[pipenv.exceptions.VirtualenvCreationException]:       clear=state.clear,
[pipenv.exceptions.VirtualenvCreationException]:   File "C:\Users\ogmamedo\AppData\Roaming\Python\Python37\site-packages\pipenv\core.py", line 574, in ensure_project
[pipenv.exceptions.VirtualenvCreationException]:       pypi_mirror=pypi_mirror,
[pipenv.exceptions.VirtualenvCreationException]:   File "C:\Users\ogmamedo\AppData\Roaming\Python\Python37\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 "C:\Users\ogmamedo\AppData\Roaming\Python\Python37\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 "C:\Users\ogmamedo\AppData\Roaming\Python\Python37\site-packages\virtualenv.py", line 939, in call_subprocess
    line = line.decode(encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xcf in position 280: invalid continuation byte

我去了文件

  

“ C:\ Users \ ogmamedo \ AppData \ Roaming \ Python \ Python37 \ site-packages \ virtualenv.py”

并更改了这样的代码:

encoding = sys.getdefaultencoding()
fs_encoding = 'OEM' #sys.getfilesystemencoding()

这有助于我在发生错误时通过该阶段(前10秒)。

为什么是“ OEM”? 因为正如我们在该文件中所看到的-调用了系统提示符(cmd shell),并且我系统的cmd shell编码为“ OEM”。

我会指出这是一种解决方法,而不是适当的解决方案,但是由于缺乏时间和兴趣,我无法确定此错误属于哪方面(pycharm或pipenv),继续寻求适当的解决方案。