Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: unknown locale: UTF-8 #187

Closed
douglasmiranda opened this issue Feb 2, 2017 · 10 comments

Comments

Projects
None yet
@douglasmiranda
Copy link

commented Feb 2, 2017

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. =]

@nateprewitt

This comment has been minimized.

Copy link
Member

commented Feb 2, 2017

Yep, looks like this is a macOS bug that locale.getlocale() can encounter. The only suggested fix is the one you've provided. Thanks for taking the time to document this :)

@nateprewitt nateprewitt closed this Feb 2, 2017

@behconsci

This comment has been minimized.

Copy link

commented Sep 26, 2017

I keep getting this even if I added the lines in .profile and .bash_profile. :/

@dragonken

This comment has been minimized.

Copy link

commented Oct 30, 2017

@behconsci , what shell are you using ?
if using zsh add in ~/.zshrc

narfdotpl added a commit to narfdotpl/dotfiles that referenced this issue Feb 2, 2018

@gangmax

This comment has been minimized.

Copy link

commented Mar 22, 2018

Adding the following lines into "~/.zshrc" fixed the problem in my environment:

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

This comment has been minimized.

Copy link

commented Apr 19, 2018

Placing this on my .bash_profile worked for me

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

This comment has been minimized.

Copy link

commented May 10, 2018

remember to source ~/.bash_profile

@pavelrad

This comment has been minimized.

Copy link

commented 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.

@erbou erbou referenced this issue May 30, 2018

Merged

first steps rewrite #251

4 of 4 tasks complete

joergrathlev added a commit to joergrathlev/dotfiles that referenced this issue Jul 12, 2018

Add locale variables
This is a workaround for pypa/pipenv#187
@gpalazuelosg

This comment has been minimized.

Copy link

commented Jul 26, 2018

hi guys,
Placing this on my .bash_profile worked for me

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

@abdallahokasha

This comment has been minimized.

Copy link

commented Jul 30, 2018

thanks @douglasmiranda it works with me.
I just need to open new terminal window even after source ~/.bash_profile and everything is ok.

@LawrenceOnen

This comment has been minimized.

Copy link

commented Jan 8, 2019

if you have to create a /.bash_profile file, then ensure you source ~/.bash_profile. Thanks to @esirK, worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.