Looks like pipenv
has trouble interacting with the terminal (see traceback below).
Pipenv should display the help prompt.
$ pipenv
Traceback (most recent call last):
File "/usr/bin/pipenv", line 11, in <module>
load_entry_point('pipenv==11.10.1', 'console_scripts', 'pipenv')()
File "/usr/lib/python3/dist-packages/pipenv/vendor/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/usr/lib/python3/dist-packages/pipenv/vendor/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/lib/python3/dist-packages/pipenv/vendor/click/core.py", line 1043, in invoke
return Command.invoke(self, ctx)
File "/usr/lib/python3/dist-packages/pipenv/vendor/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/lib/python3/dist-packages/pipenv/vendor/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/lib/python3/dist-packages/pipenv/vendor/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/lib/python3/dist-packages/pipenv/cli.py", line 275, in cli
echo(format_help(ctx.get_help()))
File "/usr/lib/python3/dist-packages/pipenv/vendor/click/utils.py", line 259, in echo
file.write(message)
UnicodeEncodeError: 'latin-1' codec can't encode character '\u2013' in position 1740: ordinal not in range(256)
I installed pipenv via the official ppa:pypa/ppa
in an Ubuntu 17.10 image running on Vagrant ("bento/ubuntu-17.10"
).
Running $ python -m pipenv.help
would say /usr/bin/python: No module named pipenv
.
Running pipenv --help
would get me the same UnicodeEncodeError.
Expicitly exporting the LC_ALL/LANG
variables in .bash_profile
or .bashrc
fixes the problem when running pipenv manually from the terminal, however the encoding issue still persists when launching pipenv through a provisioning tool (Ansible).
This is a base requirement of using click and unfortunately there is no workaround. This has been addressed in a number of other issues and it seems you already have the solution. Pipenv doeesn't have any trouble interacting with ansible, as long as you set your locale before you run it. This is a best practice you should follow with any tooling -- you should always specify your encodings before passing information around (and latin-1 is not a very good option).
Please forgive this post on a closed thread. I'm putting this here in hopes that it saves the next person who has a similar issue some time in understanding the fix.
For anyone in the US trying to follow the recommendation given above by @meronym and @techalchemy, here are 3 relatively quick steps I took to fix my issue.
I believe my issue was ultimately, the same as that of the OP.
I was having latin-1/UTF-8 issues after I git cloned my prod-to-be version up onto my Ubuntu 18.04LTS Server and then tried accessing my pipenv environment from my unprivileged user.
The error message ended thus:
.local/lib/python3.6/site-packages/pipenv/vendor/click/utils.py", line 260, in echo
file.write(message)
UnicodeEncodeError: 'latin-1' codec can't encode character '\u2026' in position 59: ordinal not in range(256)
The quick steps below were taken from the longer explanation here:
How to set up a clean UTF-8 Environment on LInux
I ensured that I had locales installed:
$ dpkg -l locales
I ensured I had some US UTF-8 locales installed, and used one as my default for all users, by running:
$ dpkg-reconfigure locales
_(note - there was a non-UTF-8 US EN Option available and highlighted for selection by default - I manually selected the UTF-8 version to provide it as the default for all users.)_
I added the following to both the .bashrc and .profile config files for my user dedicated to only running webapps:
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
After that, I logged back in as my _webapp running user_ and my pipenv sync
and pipenv shell
commands ran with the happy snake graphic, cyber-joyous green rectangles, and prideful completion without errors.
"There was much rejoicing." - Monty Python
Most helpful comment
Please forgive this post on a closed thread. I'm putting this here in hopes that it saves the next person who has a similar issue some time in understanding the fix.
For anyone in the US trying to follow the recommendation given above by @meronym and @techalchemy, here are 3 relatively quick steps I took to fix my issue.
I believe my issue was ultimately, the same as that of the OP.
I was having latin-1/UTF-8 issues after I git cloned my prod-to-be version up onto my Ubuntu 18.04LTS Server and then tried accessing my pipenv environment from my unprivileged user.
The error message ended thus:
.local/lib/python3.6/site-packages/pipenv/vendor/click/utils.py", line 260, in echo file.write(message) UnicodeEncodeError: 'latin-1' codec can't encode character '\u2026' in position 59: ordinal not in range(256)
The quick steps below were taken from the longer explanation here:
How to set up a clean UTF-8 Environment on LInux
I ensured that I had locales installed:
$ dpkg -l locales
I ensured I had some US UTF-8 locales installed, and used one as my default for all users, by running:
$ dpkg-reconfigure locales
_(note - there was a non-UTF-8 US EN Option available and highlighted for selection by default - I manually selected the UTF-8 version to provide it as the default for all users.)_
I added the following to both the .bashrc and .profile config files for my user dedicated to only running webapps:
After that, I logged back in as my _webapp running user_ and my
pipenv sync
andpipenv shell
commands ran with the happy snake graphic, cyber-joyous green rectangles, and prideful completion without errors.