Home:ALL Converter>Why is pipenv getting a UnicodeDecodeError?

Why is pipenv getting a UnicodeDecodeError?

Ask Time:2021-12-22T12:49:17         Author:whoopscheckmate

Json Formatter

Problem

I'm trying to start a virtual environment with an environment variable using pipenv. These are the steps that I followed:

  • I created a pipenv virtual environment
  • Ran echo ENV_VAR=my_token > .env
  • I started the virtual environment by running pipenv shell

When I ran that last command, I received the error:

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

I'm using PowerShell on Windows 10.

Question

Why might this happen? Clearly is some odd character getting in there, but I'm using a normal keyboard.

Context

If I simply create my .env file instead, everything works as expected. Is there something weird that happens with echo?

Additional

As requested by Giacomo Catenazzi below, I've looked at the file using Notepad++. It is in UTF-16 BOM. So the echo command simply does not work very well with PowerShell to write to UTF-8.

error

Author:whoopscheckmate,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/70444333/why-is-pipenv-getting-a-unicodedecodeerror
yy