Home >Backend Development >Python Tutorial >Why Does IPython Notebook on macOS Throw a Locale Error After Anaconda Installation, and How Can I Fix It?
IPython Notebook Locale Error
Upon installing Anaconda Python 64-bit for Mac OSX, users may encounter a ValueError when utilizing the IPython Notebook.
Problem Manifestation:
Attempting to launch IPython Notebook via:
ipython notebook
Results in the following error:
ValueError: unknown locale: UTF-8
Locale Considerations:
Executing the locale command in the terminal indicates inconsistency between the default locale and the UTF-8 encoding.
LANG= LC_COLLATE="C" LC_CTYPE="UTF-8" LC_MESSAGES="C" LC_MONETARY="C" LC_NUMERIC="C" LC_TIME="C" LC_ALL=
Solution:
To rectify the issue, adjust the locale settings in .bash_profile. For instance, to set English (US) locale, add:
export LC_ALL=en_US.UTF-8 export LANG=en_US.UTF-8
Modifying Locales:
Depending on the desired locale, users can modify the values in the above lines. To determine the current settings, use:
locale
To list available settings:
locale -a
French (Swiss) locale, for example, would require:
export LC_ALL=fr_CH.UTF-8 export LANG=fr_CH.UTF-8
After saving the changes and reloading the profile:
source ~/.bash_profile
IPython Notebook can be launched successfully without the locale error.
The above is the detailed content of Why Does IPython Notebook on macOS Throw a Locale Error After Anaconda Installation, and How Can I Fix It?. For more information, please follow other related articles on the PHP Chinese website!