I have setup a pipenv project in /home/user/code/myproject/
using
pipenv --three
I have added myproject
directory as project directory in PyCharm
and have setup environment for PyCharm
to use pipenv
from
File > Default Settings > Project Interpreter >
But when I run any command from within the console of PyCharm
like
pipenv install <package-name>
It gives error as
Traceback (most recent call last):
File "/usr/local/bin/pipenv", line 11, in <module>
sys.exit(cli())
File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 676, in main
_verify_python3_env()
File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/_unicodefun.py", line 118, in _verify_python3_env
'for mitigation steps.' + extra)
RuntimeError: Click will abort further execution because Python 3 was configured to use ASCII as encoding for the environment. Consult http://click.pocoo.org/python3/for mitigation steps.
This system lists a couple of UTF-8 supporting locales that
you can pick from. The following suitable locales where
discovered: af_ZA.UTF-8, am_ET.UTF-8, be_BY.UTF-8, bg_BG.UTF-8, ca_ES.UTF-8, cs_CZ.UTF-8, da_DK.UTF-8, de_AT.UTF-8, de_CH.UTF-8, de_DE.UTF-8, el_GR.UTF-8, en_AU.UTF-8, en_CA.UTF-8, en_GB.UTF-8, en_IE.UTF-8, en_NZ.UTF-8, en_US.UTF-8, es_ES.UTF-8, et_EE.UTF-8, eu_ES.UTF-8, fi_FI.UTF-8, fr_BE.UTF-8, fr_CA.UTF-8, fr_CH.UTF-8, fr_FR.UTF-8, he_IL.UTF-8, hr_HR.UTF-8, hu_HU.UTF-8, hy_AM.UTF-8, is_IS.UTF-8, it_CH.UTF-8, it_IT.UTF-8, ja_JP.UTF-8, kk_KZ.UTF-8, ko_KR.UTF-8, lt_LT.UTF-8, nl_BE.UTF-8, nl_NL.UTF-8, no_NO.UTF-8, pl_PL.UTF-8, pt_BR.UTF-8, pt_PT.UTF-8, ro_RO.UTF-8, ru_RU.UTF-8, sk_SK.UTF-8, sl_SI.UTF-8, sr_YU.UTF-8, sv_SE.UTF-8, tr_TR.UTF-8, uk_UA.UTF-8, zh_CN.UTF-8, zh_HK.UTF-8, zh_TW.UTF-8
How to setup the encoding in PyCharm
? Same is working fine from terminal directly.
Edit 2
The Setting > Editor > File Encoding
window shows global encoding set to UTF-8
.
Output of $ locale
in terminal
$ locale
LANG=
LC_COLLATE="C"
LC_CTYPE="en_US.UTF-8"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=
and output of $ locale
in PyCharm
console
LANG=
LC_COLLATE="C"
LC_CTYPE="C"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=
How to set appropriate encoding type? i.e., en_US.UTF-8
? I'm using Macbook Air (Sierra)
if just change the encoding of Pycharm,you can click: setting->Editor->File Encodings. It is suggested that you change all the language option to UTF-8.
You are dealing with an environment where Python 3 thinks you are restricted to ASCII data. The solution to these problems is different depending on which locale your computer is running in.
For instance, if you have a German Linux machine, you can fix the problem by exporting the locale to de_DE.utf-8:
export LC_ALL=de_DE.utf-8 export LANG=de_DE.utf-8
If you are on a US machine, en_US.utf-8 is the encoding of choice. On some newer Linux systems, you could also try C.UTF-8 as the locale:
export LC_ALL=C.UTF-8 export LANG=C.UTF-8
You need to do this before you invoke your Python script.
You could search the usage of locale and export. if you want to change the type of local setting,just use: export =value. LC_CTYPE is the most import var ,ohters are used to define the format of (money,message,date or time,etc) you can only change this to en_US.UTF-8:
export LC_CTYPE="en_US.UTF-8"
LC_ALL is a global var,it will overwrite all the LC_*(not Lang)