尝试在mac OS

时间:2018-03-22 19:26:36

标签: python python-3.x installation pipenv

我遇到以下错误:

  

警告:未设置环境变量LANG!   我们建议在〜/ .profile(或等效的)中设置它以获得正确的预期行为。   为这个项目创建virtualenv ......   使用/usr/local/opt/python/bin/python3.6(3.6.4)创建virtualenv ...   ⠋Tritraback(最近的呼叫最后一次):     在_run_module_as_main中输入文件“/usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py”,第193行       “主要”,mod_spec)     在_run_code中输入文件“/usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py”,第85行       exec(代码,run_globals)     文件“/usr/local/lib/python3.6/site-packages/pipenv/pew/ma​​in.py”,第8行,in       进口皮尤     文件“/usr/local/lib/python3.6/site-packages/pipenv/patched/pew/init.py”,第1行,in       来自。进口皮尤     文件“/usr/local/lib/python3.6/site-packages/pipenv/patched/pew/pew.py”,第41行,in       来自pew._utils import(check_call,invoke,expandpath,own,env_bin_dir,     文件“/usr/local/lib/python3.6/site-packages/pipenv/patched/pew/_utils.py”,第22行,in       encoding = locale.getlocale()[1]或'ascii'     在getlocale中输入文件“/usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/locale.py”,第581行       return _parse_localename(localename)     在_parse_localename中输入文件“/usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/locale.py”,第490行       引发ValueError('未知的语言环境:%s'%localename)   ValueError:未知语言环境:UTF-8

     

Virtualenv位置:   为此项目创建Pipfile ...   Traceback(最近一次调用最后一次):     文件“/ usr / local / bin / pipenv”,第11行,in       sys.exit(CLI())     在电话中输入文件“/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py”,第722行       return self.main(* args,** kwargs)     文件“/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py”,第697行,主要       rv = self.invoke(ctx)     文件“/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py”,第1066行,在调用中       return _process_result(sub_ctx.command.invoke(sub_ctx))     文件“/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py”,第895行,在调用中       return ctx.invoke(self.callback,** ctx.params)     在调用中输入文件“/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py”,第535行       返回回调(* args,** kwargs)     安装文件“/usr/local/lib/python3.6/site-packages/pipenv/cli.py”,第366行       selective_upgrade = selective_upgrade,     在do_install中输入文件“/usr/local/lib/python3.6/site-packages/pipenv/core.py”,第1761行       skip_requirements = skip_requirements,     在ensure_project中输入文件“/usr/local/lib/python3.6/site-packages/pipenv/core.py”,第636行       ensure_pipfile(validate = validate,skip_requirements = skip_requirements)     在ensure_pipfile中输入文件“/usr/local/lib/python3.6/site-packages/pipenv/core.py”,第289行       project.create_pipfile(蟒=蟒)     在create_pipfile中的文件“/usr/local/lib/python3.6/site-packages/pipenv/project.py”,第518行       'python_version':python_version(required_python)[:len('2.7')]   TypeError:'NoneType'对象不可订阅

我尝试在〜/ .profile和〜/ .bash_profile中设置LANG。两者都没有用。

3 个答案:

答案 0 :(得分:13)

在Mac OS X Sierra上对我有用的是将以下内容添加到我的~/bash_profile文件中:

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

然后我重新加载了bash个人资料:source ~/.bash_profile

对于使用zsh的用户,必须将这些行添加到〜/ .zshrc

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

然后我重新加载bash个人资料:source ~/.zshrc

答案 1 :(得分:2)

对于使用zsh的用户,必须将这些行添加到〜/ .zshrc

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

答案 2 :(得分:-2)

请记住,Mac OS Catalina或更高版本默认使用ZSH。跟随 在这种情况下,eInyzant的答案。