Python locale error: unsupported locale setting

Solution 1:

Run following commands

export LC_ALL="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"
sudo dpkg-reconfigure locales

It will solve this.

Make sure to match the .UTF-8 part to the actual syntax found in the output of locale -a e.g. .utf8 on some systems.

Solution 2:

According to this link, it solved by entering this command:

export LC_ALL=C