question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ValueError: unknown locale: UTF-8

See original GitHub issue

So, I was using pipenv 3.1.* or 3.2.*, now I’m using pipenv==3.3.3 on macOS Sierra.

And this happens:

Creating a Pipfile for this project...
Creating a virtualenv for this project...
Traceback (most recent call last):
  File "/usr/local/bin/pew", line 7, in <module>
    from pew.pew import pew
  File "/usr/local/lib/python2.7/site-packages/pew/__init__.py", line 11, in <module>
    from . import pew
  File "/usr/local/lib/python2.7/site-packages/pew/pew.py", line 36, in <module>
    from pew._utils import (check_call, invoke, expandpath, own, env_bin_dir,
  File "/usr/local/lib/python2.7/site-packages/pew/_utils.py", line 22, in <module>
    encoding = locale.getlocale()[1] or 'ascii'
  File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 564, in getlocale
    return _parse_localename(localename)
  File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 477, in _parse_localename
    raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: UTF-8

A strange thing, since I didn’t changed anything on macOS locale settings, but I’ve fixed by adding, on my ~/.bash_profile (~/.zshrc):

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

I don’t know if anyone will have the same issue, but if this is not something for pipenv to bypass without error or something, you can close the issue. =]

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:276
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

22reactions
alexmochucommented, Apr 20, 2018

Placing this on my .bash_profile worked for me

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
20reactions
pavelradcommented, May 14, 2018

Seems this is caused by terminal apps automatically setting locale variables. Both iTerm and Terminal.app have an option “Set locale variables…” enabled by default and set LC_CTYPE=UTF-8. Unsetting this envvar removes the problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

"ValueError: unknown locale: UTF-8" when importing pandas ...
Looks like you're on OS X. Append this to your ~/.bash_profile : export LC_ALL=en_US.UTF-8 export LANG=en_US.UTF-8. And then run:
Read more >
How To Fix Python Error ValueError: unknown locale: UTF-8 ...
Solution ; export LC_ALL=en_US.UTF-8 export LANG=en_US.UTF-8 ; export LC_CTYPE=en_US.UTF-8 ; # bash source ~/.bash_profile # zsh source ~/.zshrc.
Read more >
Mac OS X: ValueError: unknown locale: UTF-8 in Python
A protip by masnun about python, osx, mac, django, utf8, valueerror, and locale.
Read more >
MacOS X: ValueError: unknown locale: UTF-8 (Fixed)
Solving valueError: unknown locale: UTF-8 on ubuntu, mac os x and others when running Python scripts.
Read more >
crucible.py shows 'ValueError: unknown locale: UTF-8' on ...
crucible.py shows 'ValueError: unknown locale: UTF-8' on some environments ; Fix version/s: 3.9.1 ; Label/s. review-cli ; Reporter: Lukasz Pater ; Votes: 0....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found