Unsupported locale setting windows

типун установить локаль.Ошибка: неподдерживаемый параметр локали

на том же сервере я успешно запустил pip install virtualenv С python 2.7.x.

теперь, я только что установил python3. 4 с помощью curl https://bootstrap.pypa.io/get-pip.py | python3.4 .

pip uninstall virtualenv выдает ту же ошибку тоже

8 ответов:

основная причина: ваша переменная окружения LC_ALL отсутствует или недействителен как-то

короткий ответ-

просто выполните следующую команду:

длинный ответ-

вот мой locale параметры:

выполните следующую команду (она будет работать):

кто-то может найти это полезным. Вы можете поместить эти настройки локали .файл bashrc, который обычно находится в домашнем каталоге.
Просто добавьте эту команду .bashrc следующее:
export LC_ALL=C
затем введите source .bashrc
Теперь вам не нужно вызывать эту команду вручную каждый раз, когда вы подключаетесь через ssh, например.

хотя вы можете установить языковой стандарт экспорта переменной env, вам придется делать это каждый раз, когда вы начинаете сеанс. Установка локали таким образом решит проблему навсегда:

для Dockerfile, это работает для меня:

Как установить locale-gen?

[этот ответ предназначен только для платформы linux]

первое, что вы должны знать, это большая часть локали конфигурационный файл, расположенный путь может быть получить от localedef —help :

посмотреть последний /usr/share/i18n ? Здесь находится ваш конфигурационный файл xx_XX. UTF-8:

теперь что ? Нам нужно скомпилировать их в двоичный архив. Один из способов, например, предположим, что у меня есть /usr/share/i18n/locales/en_LOVE , Я могу добавить его в список компиляции, т. е. /etc/locale-gen файл:

и скомпилировать его в двоичный код sudo locale-gen :

а теперь обновите системную локаль по умолчанию с нужным LANG , LC_ALL . и т. д. С этой update-locale :

update-locale на самом деле также означает, обновлять /etc/default/locale файл, который будет источником системой при входе в систему для установки переменных среды:

но мы можем не захотеть перезагружаться, чтобы вступить в силу, поэтому мы можем просто отправить его в переменную окружения в текущая сессия оболочки:

как о sudo dpkg-reconfigure locales ? Если вы играете вокруг него, вы будете знать, что эта команда в основном действует как графический интерфейс для упрощения вышеуказанных шагов, т. е. Edit /etc/locale.gen -> sudo locale-gen -> sudo update-locale LANG=en_LOVE.UTF-8

для python, пока /etc/locale.gen содержит этот кандидат локали и locale.gen компилируется, setlocale(category, locale) должен работать без бросков locale.Error: unsupoorted locale setting . Вы можете проверить правильность строки en_US.UTF-8 / en_US/. etc установить в setlocale() , путем наблюдения

у меня такая же проблема, и «export LC_ALL=c» не работает для меня,
Попробуй export LC_ALL=»en_US.UTF-8″ (Она будет работать).

сообщение об ошибке указывает на проблему с настройкой локали. Чтобы исправить это, как указано в других ответах, вам нужно изменить свой языковой стандарт.

на Mac OS X Sierra я обнаружил, что лучший способ сделать это-изменить

/bash_profile файл выглядит следующим образом:

это изменение не будет сразу видно в текущем сеансе cli, если вы не перезагрузите профиль bash с помощью: source

этот ответ довольно близок к ответам, которые я опубликовал другие неидентичные, не повторяющиеся вопросы (т. е. не связанные с pipenv), но которые требуют одного и того же решения.

Читайте также:  Vmware для linux manjaro

модератору: с уважением; мой предыдущий ответ был удален по этой причине, но я чувствую, что это было немного глупо, потому что на самом деле этот ответ применяется почти всякий раз, когда ошибка «проблема с locale». но есть ряд различных ситуаций, языков и сред, которые могут вызвать эту ошибку.

таким образом, это а) не имеет смысла отметьте вопросы как дубликаты и б) не имеет смысла адаптировать ответ либо потому, что исправление очень просто, одинаково в каждом случае и не выигрывает от украшения.

Unsupported Locale Setting on Windows #75

Comments

brinew27 commented Mar 10, 2018

When I install Lore and try to create a test app using the code listed in the blog post:

I get the following stack trace:

I tried Googling around a bit for this issue but couldn’t find a good resolution.

The text was updated successfully, but these errors were encountered:

montanalow commented Mar 13, 2018

I will take a look on my windows machine when I get home. pyenv does not support windows, and is how Lore manages dependencies, so this may be tricky to get around.

montanalow commented Mar 13, 2018

@oltip sorry about the delete, your comment was showing twice and I was trying to clean up the thread. It has been noted as a +1.

brinew27 commented Mar 14, 2018

Just as an FYI, after doing my own Googling, I say that this was a way to get around this was to adjust:

This seems to have resolved the issue for now.

montanalow commented Mar 14, 2018 •

@brinew27 can you help test this patch on your system? My box is Windows 10. The caveat is the —python-version flag will be ignored on windows and whatever python version is installed will be used in the local virtualenv instead.

  1. pip uninstall lore
  2. pip install -e git+https://github.com/instacart/lore@montana/windows#egg=lore
  3. pip install python-dateutil==2.6
  4. lore init my_app —keras
  5. replace lore==. with -e git+https://github.com/instacart/lore@montana/windows#egg=lore in requirements.txt in your project directory.
  6. cd my_app
  7. lore install

Then you should be good to continue with demo

How to fix locale.Error: unsupported locale setting in Python

Python is a popular general purpose programming language that can be used to serve many different use cases. Created by Guido van Rossum with the name inspired from British comedy show Monty Python, it was set out to be straightforward and easy-to-use, emphasized in wp-block-code readability. Python 3 is the latest version of the language and is considered to be the future of Python.

The set up of Python 3 on your Linux machine should be straightforward without any error, but sometimes you will encounter locale.Error: unsupported locale setting – one of the most common problem of Python. This tutorial will show you how to fix it explicitly on Ubuntu 18.04, but the process remains the same for other distro.

When does locale.Error happens?

The root cause is: your environment variable LC_ALL is missing or invalid somehow

locale.Error could be triggered when you :

  • Using pip to install a package that make use of locale package on a newly installed machine
  • Using virtualenv to make a new virtual environment
  • You’ve been fiddling with the environment variables then try to use pip
  • Running programs built with Python for the first time after fresh OS installation.
  • Sometimes it happens with programs like ssh, a2enmod, and perl programs too.
Читайте также:  Создание своего сервиса linux

How to fix locale.Error quickly?

If you want to solve it quick, you can sequentially run the commands below in the terminal :

The first two commands set the LC_ALL and LC_CTYPE environment variables, then the third one commits the changes to the system. After running these, a few command-line style window could probably pop up, you can just hit OK until it’s done, there is pretty much nothing to configure.

Here is a one-liner for you the lazy guys :

The output should look like this :

Fix locale.Error permanently

While you can set the locale exporting an environment variable, you will have to do that every time you start a session, meaning after a restart, things would go back the same as before. Setting a locale the following way will solve the problem permanently.

First, you need to install locales package :

Then use the locale-gen command to generate locales :

After that, permanently set the configuration to the system

You might also need to restart your system for changes to take effect.

Fix locale.Error for Docker

Just add these lines to your Dockerfile

After setting the locale, verify that the system is updated by using the following command :

Python locale error: unsupported locale setting

Why do I get the following error when doing this in python:

This works with other locales like fr or nl as well. I’m using Ubuntu 11.04.

Update: Doing the following did not yield anything:

21 Answers 21

Run following commands

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.

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

You probably do not have any de_DE locale available.

You can view a list of available locales with the locale -a command. For example, on my machine:

Note that if you want to set the locale to it_IT you must also specify the .utf8 :

To install a new locale use:

where id is the language code (taken from here)

After you have installed the locale you should follow Julien Palard advice and reconfigure the locales with:

One of the above answer provides the solution:

The problem with above solution is that it has to be done on the linux shell. However, if you are providing your code to work on the client machine then this is a bad approach. I also tried executing the above commands using os.system(), but still it doesn’t work.

Solution that worked for me is

More permanent solution would be to fill the missing values, in the output shown by command: locale

Output from locale is:

To Fill the missing values edit

Add the following lines after the above command (suppose you want en_US.UTF-8 to be your language):

If this file is ReadOnly you would be needing to follow the steps mentioned by The GeekyBoy. The answer given by Dr Beco in Superuser has details relating to saving readonly files.

After saving the file do:

Now you wont be facing the same problem anymore.

If you’re on a Debian (or Debian fork), you can add locales using :

Читайте также:  Отключение служб windows через командную строку

You error clearly says, you are trying to use locale something was not there.

locale.Error: unsupported locale setting

To check available setting, use locale -a

so you can use one among,

This file can either be adjusted manually or updated using the tool, update-locale.

On Arch Linux I was able to fix this by running sudo locale-gen

For the record, I had this same problem, but none of the solutions worked. I had upgraded my computer and migrated my PC. I had a a mixed locale english and spanish:

But, on my new Debian installation, I just selected english as locale. Which finally worked was to reconfigure locales package to add and generate spanish too.

Place it in the Dockerfile above the ENV .

Just open the .bashrc file and add this

and then type source .bashrc in terminal.

  • run this command locale to get what locale is used. Such as:

LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_CTYPE=zh_CN.UTF-8
LC_NUMERIC=»en_US.UTF-8″
LC_TIME=»en_US.UTF-8″
LC_COLLATE=»en_US.UTF-8″
LC_MONETARY=»en_US.UTF-8″
LC_MESSAGES=»en_US.UTF-8″
LC_PAPER=»en_US.UTF-8″
LC_NAME=»en_US.UTF-8″
LC_ADDRESS=»en_US.UTF-8″
LC_TELEPHONE=»en_US.UTF-8″
LC_MEASUREMENT=»en_US.UTF-8″
LC_IDENTIFICATION=»en_US.UTF-8″
LC_ALL=

  • search for the listed locales list in first step in /etc/locale-gen file. Uncomment to used ones
  • run locale-gen to generate newly added locales

In my opinion, the easiest way to setup the local locale in python <,3>is:

Then, locale aware stuff just works, if you’re on a decent linux distro, and should work on binary distributions of the other OSes as well (or that’s a bug IMHO).

This error can occur, if you have just added a new locale. You need to restart the python interactive shell ( quit( ) and python ) to get access to it.

I got the same issue here using Docker, I’ve tried every single step and didn’t work well, always getting locale error, so I decided to use BABEL, and everything worked well.

For those deploying a docker image and using a locale that isn’t shown in the locale -a command, add this line to your Dockerfile
RUN apt-get install -y locales

This should add all locales to your image, I used de_DE which is not part of AWS default Ubuntu server.

In trying to get python to spit out names in specific locale I landed here with same problem.

In pursuing the answer, things got a little mystical I find.

I found that python code.

And indeed locale.setlocale(locale.LC_TIME, ‘en_DK.UTF-8’) works

Using tips here I tested further to see what is available using python code

Of which only above is working! But the en_DK.UTF-8 is not in this list, though it works. What?? And the python generated locale list do contain a lot of combos of da and DK, which I am looking for, but again no UTF-8 for da/DK.

I am on a Point Linux distro (Debian based), and here locale says amongst other LC_TIME=»en_DK.UTF-8″ , which I know works, but not the locale I need.

So definitely need to install other locale, which i did by editing /etc/locale.gen , uncomment needed line da_DK.UTF-8 UTF-8 and run command locale-gen

Now locale.setlocale(locale.LC_TIME, ‘da_DK.UTF-8’) works too, and I can get my localized day and month names.

My Conclision:

Python : locale.locale_alias is not at all helpfull in finding available locales.

Linux : It is quite easy to get locale list and install new locale. A lot of help available.

Windows : I have been investigating a little, but nothing conclusive. There are though posts leading to answers, but I have not felt the urge to pursue it.

Оцените статью