ValueError: unknown locale: UTF-8

Macbook Pro安装spacy英文包时报错。

运行代码:

python -m spacy download en

错误:

Traceback (most recent call last):
  File "/Users/gzit000633/anaconda3/lib/python3.6/runpy.py", line 183, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/Users/gzit000633/anaconda3/lib/python3.6/runpy.py", line 142, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "/Users/gzit000633/anaconda3/lib/python3.6/runpy.py", line 109, in _get_module_details
    __import__(pkg_name)
  File "/Users/gzit000633/Documents/Python/cca_chatbot/virtualenv_ccac/lib/python3.6/site-packages/spacy/__init__.py", line 4, in 
    from .cli.info import info as cli_info
  File "/Users/gzit000633/Documents/Python/cca_chatbot/virtualenv_ccac/lib/python3.6/site-packages/spacy/cli/__init__.py", line 1, in 
    from .download import download
  File "/Users/gzit000633/Documents/Python/cca_chatbot/virtualenv_ccac/lib/python3.6/site-packages/spacy/cli/download.py", line 11, in 
    from .link import link
  File "/Users/gzit000633/Documents/Python/cca_chatbot/virtualenv_ccac/lib/python3.6/site-packages/spacy/cli/link.py", line 9, in 
    from ..util import prints
  File "/Users/gzit000633/Documents/Python/cca_chatbot/virtualenv_ccac/lib/python3.6/site-packages/spacy/util.py", line 8, in 
    import regex as re
  File "/Users/gzit000633/Documents/Python/cca_chatbot/virtualenv_ccac/lib/python3.6/site-packages/regex.py", line 683, in 
    _pattern_type = type(_compile("", 0, {}))
  File "/Users/gzit000633/Documents/Python/cca_chatbot/virtualenv_ccac/lib/python3.6/site-packages/regex.py", line 436, in _compile
    pattern_locale = _getlocale()[1]
  File "/Users/gzit000633/Documents/Python/cca_chatbot/virtualenv_ccac/lib/python3.6/locale.py", line 581, in getlocale
    return _parse_localename(localename)
  File "/Users/gzit000633/Documents/Python/cca_chatbot/virtualenv_ccac/lib/python3.6/locale.py", line 490, in _parse_localename
    raise ValueError('unknown locale: %s' % localename)
ValueError: unknown locale: UTF-8

解决方案:

step1:

vi ~/.bashrc

step2: 添加

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

step3: 

source ~/.bashrc

step4:

重新安装。

你可能感兴趣的:(安装报错)