docker-compose up: utf-8 codec can't decode byte X
Question:
Everytime I run docker-compose up on my machine (macOS 10.13.5, latest docker version) I get this error
Traceback (most recent call last): File “docker-compose”, line 6, in
File “compose/cli/main.py”, line 71, in main File
“compose/cli/main.py”, line 124, in perform_command File
“compose/cli/command.py”, line 41, in project_from_options File
“compose/cli/command.py”, line 126, in get_project File
“compose/project.py”, line 96, in from_config File
“compose/network.py”, line 320, in get_networks File
“compose/network.py”, line 125, in true_name File
“compose/network.py”, line 146, in _set_legacy_flag File
“compose/network.py”, line 106, in inspect File
“site-packages/docker/utils/decorators.py”, line 19, in wrapped File
“site-packages/docker/api/network.py”, line 211, in inspect_network
File “site-packages/docker/utils/decorators.py”, line 46, in inner
File “site-packages/docker/api/client.py”, line 194, in _get File
“site-packages/requests/sessions.py”, line 521, in get File
“site-packages/requests/sessions.py”, line 494, in request File
“site-packages/requests/sessions.py”, line 424, in prepare_request
File “site-packages/requests/utils.py”, line 195, in get_netrc_auth
File “netrc.py”, line 33, in init File “netrc.py”, line 42, in
_parse File “shlex.py”, line 105, in get_token File “shlex.py”, line 136, in read_token File
“/Users/distiller/compose-osx-release/compose/venv/lib/python3.6/codecs.py”,
line 321, in decode UnicodeDecodeError: ‘utf-8’ codec can’t decode
byte 0x80 in position 33: invalid start byte
Answers:
I have 2 ideas:
1. try to reinstall your python
2. use not the latest docker version, but the latest stable
Ok so apparently there is a problem with the current version of docker-compose for macOS… It’s just my guess, but anyhow here is how I solved it
curl -L https://github.com/docker/compose/releases/download/1.14.0-rc2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
Then restarted the terminal
What worked for me was creating an empty .env file in the directory I run docker-compose in (encoded as UTF-8).
I ran into this same issue and this may also be related to your .env
files.
Ensure that your .env files are UTF-8.
sudo apt install moreutils
isutf8 yourfile.env
If isutf8
returns no output it’s likely a valid UTF-8 file.
Additionally, check the contents of the .env file you’re referencing in your docker-compose.yml. Any incorrectly decrypted secrets/values you may be using locally can cause this problem too.
If in doubt, clear the env file and readd lines until you hit the error.
you need to go to the pycharm env file, double click it and install the python env file. Then run the code [docker-compose up airflow-init] again, it’ll work.
Everytime I run docker-compose up on my machine (macOS 10.13.5, latest docker version) I get this error
Traceback (most recent call last): File “docker-compose”, line 6, in
File “compose/cli/main.py”, line 71, in main File
“compose/cli/main.py”, line 124, in perform_command File
“compose/cli/command.py”, line 41, in project_from_options File
“compose/cli/command.py”, line 126, in get_project File
“compose/project.py”, line 96, in from_config File
“compose/network.py”, line 320, in get_networks File
“compose/network.py”, line 125, in true_name File
“compose/network.py”, line 146, in _set_legacy_flag File
“compose/network.py”, line 106, in inspect File
“site-packages/docker/utils/decorators.py”, line 19, in wrapped File
“site-packages/docker/api/network.py”, line 211, in inspect_network
File “site-packages/docker/utils/decorators.py”, line 46, in inner
File “site-packages/docker/api/client.py”, line 194, in _get File
“site-packages/requests/sessions.py”, line 521, in get File
“site-packages/requests/sessions.py”, line 494, in request File
“site-packages/requests/sessions.py”, line 424, in prepare_request
File “site-packages/requests/utils.py”, line 195, in get_netrc_auth
File “netrc.py”, line 33, in init File “netrc.py”, line 42, in
_parse File “shlex.py”, line 105, in get_token File “shlex.py”, line 136, in read_token File
“/Users/distiller/compose-osx-release/compose/venv/lib/python3.6/codecs.py”,
line 321, in decode UnicodeDecodeError: ‘utf-8’ codec can’t decode
byte 0x80 in position 33: invalid start byte
I have 2 ideas:
1. try to reinstall your python
2. use not the latest docker version, but the latest stable
Ok so apparently there is a problem with the current version of docker-compose for macOS… It’s just my guess, but anyhow here is how I solved it
curl -L https://github.com/docker/compose/releases/download/1.14.0-rc2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
Then restarted the terminal
What worked for me was creating an empty .env file in the directory I run docker-compose in (encoded as UTF-8).
I ran into this same issue and this may also be related to your .env
files.
Ensure that your .env files are UTF-8.
sudo apt install moreutils
isutf8 yourfile.env
If isutf8
returns no output it’s likely a valid UTF-8 file.
Additionally, check the contents of the .env file you’re referencing in your docker-compose.yml. Any incorrectly decrypted secrets/values you may be using locally can cause this problem too.
If in doubt, clear the env file and readd lines until you hit the error.
you need to go to the pycharm env file, double click it and install the python env file. Then run the code [docker-compose up airflow-init] again, it’ll work.