Guidelines

This site is for tech Q&A. Please keep your posts focused on the subject at hand.

Ask one question at a time. Don't conflate multiple problems into a single question.

Make sure to include all relevant information in your posts. Try to avoid linking to external sites.

Links to documentation are fine, but in addition you should also quote the relevant parts in your posts.

0 votes
222 views
222 views

When trying to install a Python module with pip3 I received the following error:

Traceback (most recent call last):
  File "/usr/bin/pip3", line 11, in <module>
    sys.exit(main())
  File "/usr/lib/python3/dist-packages/pip/\__init__.py", line 215, in main
    locale.setlocale(locale.LC_ALL, '')
  File "/usr/lib/python3.5/locale.py", line 594, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting

Why?

in Scripting
by (100)
1 4 11
edit history

Your answer

Preview

Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
By submitting this post you agree to our Terms & Conditions.
To avoid this verification in future, please log in or register.

1 Answer

0 votes
 

The statement locale.setlocale(locale.LC_ALL, '') tries to set the locale to the user's default locale. From the documentation:

setlocale() is not thread-safe on most systems. Applications typically start with a call of

import locale
locale.setlocale(locale.LC_ALL, '')

This sets the locale for all categories to the user’s default setting (typically specified in the LANG environment variable). If the locale is not changed thereafter, using multithreading should not cause problems.

Typically the error means that the environment variable LC_ALL (not LANG) is either not set or set to an invalid locale (like an empty string). You can check that via the printenv command:

printenv | grep LC_ALL

To fix the issue set LC_ALL to a valid locale before running pip3:

export LC_ALL='C'
pip3 install ...

"C" is the preferred locale for system administration tasks.

by (100)
1 4 11
edit history
...