Full stacktrace:
? ~ pip install virtualenv
Traceback (most recent call last):
File "/usr/bin/pip", line 11, in <module>
sys.exit(main())
File "/usr/lib/python3.4/site-packages/pip/__init__.py", line 215, in main
locale.setlocale(locale.LC_ALL, '')
File "/usr/lib64/python3.4/locale.py", line 592, in setlocale
return _setlocale(category, locale)
locale.Error: unsupported locale setting
On the same server, I successfully ran pip install virtualenv
with python 2.7.x.
Now, I've just installed python3.4 using curl https://bootstrap.pypa.io/get-pip.py | python3.4
.
? ~ pip --version
pip 8.1.1 from /usr/lib/python3.4/site-packages (python 3.4)
pip uninstall virtualenv
throws the same error too
This question is related to
python
python-3.x
centos
pip
While you can set the locale exporting an env variable, you will have to do that every time you start a session. Setting a locale this way will solve the problem permanently:
sudo apt-get install locales
sudo locale-gen en_US.UTF-8
sudo echo "LANG=en_US.UTF-8" > /etc/default/locale
The error message indicates a problem with the locale setting. To fix this as indicated by other answers you need to modify your locale.
On Mac OS X Sierra I found that the best way to do this was to modify the ~/bash_profile
file as follows:
export LANG="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"
This change will not be immediately evident in your current cli session unless you reload the bash profile by using: source ~/.bash_profile
.
This answer is pretty close to answers that I've posted to other non-identical, non-duplicate questions (i.e. not related to pipenv) but which happen to require the same solution.
To the moderator: With respect; my previous answer got deleted for this reason but I feel that was a bit silly because really this answer applies almost whenever the error is "problem with locale"... but there are a number of differing situations, languages, and environments which could trigger that error.
Thus it A) doesn't make sense to mark the questions as duplicates and B) doesn't make sense to tailor the answer either because the fix is very simple, is the same in each case and does not benefit from ornamentation.
Run the following command (it will work):
export LC_ALL="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"
sudo dpkg-reconfigure locales
Ubuntu:
$ sudo vi /etc/default/locale
Add below setting at the end of file.
LC_ALL = en_US.UTF-8
Someone may find it useful. You could put those locale settings in .bashrc file, which usually located in the home directory.
Just add this command in .bashrc:
export LC_ALL=C
then type source .bashrc
Now you don't need to call this command manually every time, when you connecting via ssh for example.
For Dockerfile, this works for me:
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
How to install locale-gen?
[This answer is target on linux platform only]
The first thing you should know is most of the locale config file located path can be get from localedef --help
:
$ localedef --help | tail -n 5
System's directory for character maps : /usr/share/i18n/charmaps
repertoire maps: /usr/share/i18n/repertoiremaps
locale path : /usr/lib/locale:/usr/share/i18n
For bug reporting instructions, please see:
<https://bugs.launchpad.net/ubuntu/+source/glibc/+bugs>
See the last /usr/share/i18n
? This is where your xx_XX.UTF-8 config file located:
$ ls /usr/share/i18n/locales/zh_*
/usr/share/i18n/locales/zh_CN /usr/share/i18n/locales/zh_HK /usr/share/i18n/locales/zh_SG /usr/share/i18n/locales/zh_TW
Now what ? We need to compile them into archive binary. One of the way, e.g. assume I have /usr/share/i18n/locales/en_LOVE
, I can add it into compile list, i.e. /etc/locale-gen
file:
$ tail -1 /etc/locale.gen
en_LOVE.UTF-8 UTF-8
And compile it to binary with sudo locale-gen
:
$ sudo locale-gen
Generating locales (this might take a while)...
en_AG.UTF-8... done
en_AU.UTF-8... done
en_BW.UTF-8... done
...
en_LOVE.UTF-8... done
Generation complete.
And now update the system default locale with desired LANG
, LC_ALL
...etc with this update-locale
:
sudo update-locale LANG=en_LOVE.UTF-8
update-locale
actually also means to update this /etc/default/locale
file which will source by system on login to setup environment variables:
$ head /etc/default/locale
# File generated by update-locale
LANG=en_LOVE.UTF-8
LC_NUMERIC="en_US.UTF-8"
...
But we may not want to reboot to take effect, so we can just source it to environment variable in current shell session:
$ . /etc/default/locale
How about sudo dpkg-reconfigure locales
? If you play around it you will know this command basically act as GUI to simplify the above steps, i.e. Edit /etc/locale.gen
-> sudo locale-gen
-> sudo update-locale LANG=en_LOVE.UTF-8
For python, as long as /etc/locale.gen
contains that locale candidate and locale.gen
get compiled, setlocale(category, locale)
should work without throws locale.Error: unsupoorted locale setting
. You can check the correct string en_US.UTF-8
/en_US/....etc
to be set in setlocale()
, by observing /etc/locale.gen
file, and then uncomment and compile it as desired. zh_CN GB2312
without dot in that file means the correct string is zh_CN
and zh_CN.GB2312
.
I had the same problem, and "export LC_ALL=c"
didn't work for me.
Try export LC_ALL="en_US.UTF-8"
(it will work).
Source: Stackoverflow.com