Home >Backend Development >Python Tutorial >How to Fix the IPython Notebook 'unknown locale: UTF-8' Error on macOS?
IPython Notebook Locale Error
When attempting to start IPython Notebook on a Mac OSX 64-bit Anaconda Python installation, users may encounter a ValueError. This error originates from an unknown locale setting.
Problem Details
The error message typically includes the following traceback:
ValueError: unknown locale: UTF-8
Examining the system locale settings using the command locale reveals the following:
LANG= LC_COLLATE="C" LC_CTYPE="UTF-8" LC_MESSAGES="C" LC_MONETARY="C" LC_NUMERIC="C" LC_TIME="C" LC_ALL=
Solution
To resolve this error, set the locale explicitly. The following steps provide instructions for configuring the locale:
export LC_ALL=en_US.UTF-8 export LANG=en_US.UTF-8
source ~/.bash_profile
ipython notebook
Modifying Locales
The settings provided above are specific to the English language in a US locale. Users may require different settings depending on their language and regional preferences.
To view the current system locale settings, use the command:
$ locale
To retrieve a list of all valid locale settings, enter:
$ locale -a
Choose the preferred locale and update the appropriate lines in the .bash_profile file. For instance, to configure a Swiss French locale, use the following settings:
export LC_ALL=fr_CH.UTF-8 export LANG=fr_CH.UTF-8
The above is the detailed content of How to Fix the IPython Notebook 'unknown locale: UTF-8' Error on macOS?. For more information, please follow other related articles on the PHP Chinese website!