我是python和virtualenv的新手。我已经安装了pip并安装了virtualenv,通过它我下载了python NLP库spacy。现在我在下载语言库时遇到了问题。我运行的命令是:
$ python3 -m spacy download en
我得到的错误是:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 183, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 142, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 109, in _get_module_details
__import__(pkg_name)
File "/Users/JoshiMac/Documents/pythonprojects/LangEnv/lib/python3.6/site-packages/spacy/__init__.py", line 4, in <module>
from .cli.info import info as cli_info
File "/Users/JoshiMac/Documents/pythonprojects/LangEnv/lib/python3.6/site-packages/spacy/cli/__init__.py", line 1, in <module>
from .download import download
File "/Users/JoshiMac/Documents/pythonprojects/LangEnv/lib/python3.6/site-packages/spacy/cli/download.py", line 11, in <module>
from .link import link
File "/Users/JoshiMac/Documents/pythonprojects/LangEnv/lib/python3.6/site-packages/spacy/cli/link.py", line 9, in <module>
from ..util import prints
File "/Users/JoshiMac/Documents/pythonprojects/LangEnv/lib/python3.6/site-packages/spacy/util.py", line 8, in <module>
import regex as re
File "/Users/JoshiMac/Documents/pythonprojects/LangEnv/lib/python3.6/site-packages/regex.py", line 683, in <module>
_pattern_type = type(_compile("", 0, {}))
File "/Users/JoshiMac/Documents/pythonprojects/LangEnv/lib/python3.6/site-packages/regex.py", line 436, in _compile
pattern_locale = _getlocale()[1]
File "/Users/JoshiMac/Documents/pythonprojects/LangEnv/lib/python3.6/locale.py", line 581, in getlocale
return _parse_localename(localename)
File "/Users/JoshiMac/Documents/pythonprojects/LangEnv/lib/python3.6/locale.py", line 490, in _parse_localename
raise ValueError('unknown locale: %s' % localename)
ValueError: unknown locale: UTF-8
答案 0 :(得分:0)
请参阅https://github.com/explosion/spaCy/issues/1684。 在您的bash中添加以下内容
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8