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.