Python: ValueError: unknown locale: UTF-8

When installing bioservices (a python package) using pip or easy_install, I got this error Mac OS X 10.7 – Lion:

ValueError: unknown locale: UTF-8

Although the installation is successful, the error will appear as soon as we try:

from bioservices import *.

On solution is to fix your environment by typing the following code in a shell:

export LANG="it_IT.UTF-8"
export LC_COLLATE="it_IT.UTF-8"
export LC_CTYPE="it_IT.UTF-8"
export LC_MESSAGES="it_IT.UTF-8"
export LC_MONETARY="it_IT.UTF-8"
export LC_NUMERIC="it_IT.UTF-8"
export LC_TIME="it_IT.UTF-8"
export LC_ALL=

You can check if it works by typing

python -c 'import locale; print(locale.getdefaultlocale());'

If this works without error, then it is fixed and you should be able to import bioservices. If so, make this solution persistent by adding the code into your environment. For that, just copy and paste the code in a file called .bashrc_profile (or .bashrc)

Reference: http://patrick.arminio.info/blog/2012/02/fix-valueerror-unknown-locale-utf8/

Please follow and like us:
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published.