question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

UnicodeDecodeError when running pipenv install on Windows

See original GitHub issue

Issue description

I’m installing a pipenv virtual env from a virtualenv project that has a requirement.txt, but it doesn’t matter, I can’t run any pipenv commands, even pipenv --support.

Expected result

Installation should be successful.

Actual result

pipenv install or pipenv --support

Traceback (most recent call last): File “c:\users\panzi\appdata\local\programs\python\python36\lib\runpy.py”, line 193, in run_module_as_main “main”, mod_spec) File “c:\users\panzi\appdata\local\programs\python\python36\lib\runpy.py”, line 85, in run_code exec(code, run_globals) File "C:\Users\panzi\AppData\Local\Programs\Python\Python36\Scripts\pipenv.exe_main.py", line 5, in <module> File "c:\users\panzi\appdata\local\programs\python\python36\lib\site-packages\pipenv_init.py", line 47, in <module> from .cli import cli File “c:\users\panzi\appdata\local\programs\python\python36\lib\site-packages\pipenv\cli_init_.py”, line 3, in <module> from .command import cli File “c:\users\panzi\appdata\local\programs\python\python36\lib\site-packages\pipenv\cli\command.py”, line 7, in <module> import crayons File “c:\users\panzi\appdata\local\programs\python\python36\lib\site-packages\pipenv\patched\crayons.py”, line 49, in <module> is_powershell = “powershell” in shellingham.detect_shell()[0] File “c:\users\panzi\appdata\local\programs\python\python36\lib\site-packages\pipenv\vendor\shellingham_init_.py”, line 22, in detect_shell shell = get_shell(pid, max_depth=max_depth) File “c:\users\panzi\appdata\local\programs\python\python36\lib\site-packages\pipenv\vendor\shellingham\nt.py”, line 100, in get_shell processes = dict(_iter_process()) File “c:\users\panzi\appdata\local\programs\python\python36\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 0xc3 in position 2: invalid continuation byte

Steps to replicate

pipenv install


After some debugging, I found it’s a decoding bug in Python36\Lib\site-packages\pipenv\vendor\shellingham\nt.py

I added a try catch to capture the exception and try to decode it in my locale encoding, then it succeeded. Is there a more elegant way to fix it?

def _iter_process():
   ...
        try:
            info = {'executable': str(pe.szExeFile.decode('utf-8'))}
        except UnicodeDecodeError:
            info = {'executable': str(pe.szExeFile.decode('GBK'))}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:28 (11 by maintainers)

github_iconTop GitHub Comments

3reactions
pansilacommented, Oct 29, 2019

When can we include this fix? There are no releases for almost a year since the last pipenv release. https://github.com/sarugaku/shellingham/commit/381372076a075dd3e5eea9d1cfe6644e48b60aa8

3reactions
nexcvoncommented, Aug 17, 2019

Same error when running pipenv install, on Windows 10 (Chinese). Caused by some network errors in Chinese. Fixed by adding an environment variable: PYTHONLEGACYWINDOWSFSENCODING=mbcs

Read more comments on GitHub >

github_iconTop Results From Across the Web

use pipenv -h, UnicodeDecodeError: 'utf-8' - Stack Overflow
I was tryin to install PIPEnvironment through Pycharm interpreter settings and ... Failed creating virtual environment [pipenv.exceptions.
Read more >
pipenv Changelog - PyUp.io
- Adjust pipenv to work with the newly added ``venv`` install scheme in Python. First check if ``venv`` is among the available install...
Read more >
pipenv install命令创建python虚拟环境报错 - CSDN博客
decode(fs_encoding) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd4 in position 40: invalid continuation byte Failed to create virtual ...
Read more >
python - setup.py install for pylibmc ... error when pip install -r ...
win-amd64-3.7\pylibmc running build_ext building '_pylibmc' extension error: Microsoft Visual C++ 14.0 or greater is required. Get it with " ...
Read more >
[Example code]-pip install tabulate UnicodeDecodeError
I'm trying to install the python package tabulate by running pip3 install tabulate on Archlinux but i got the following error:
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found