我尝试在我的python代码(Mac OS)中导入nltk库。我收到此错误消息。我应该安装一个特定的nltk软件吗?或者在终端中写什么正确的命令?
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import nltk
File "/Library/Python/2.7/site-packages/nltk/__init__.py", line 128, in <module>
from nltk.chunk import *
File "/Library/Python/2.7/site-packages/nltk/chunk/__init__.py", line 157, in <module>
from nltk.chunk.api import ChunkParserI
File "/Library/Python/2.7/site-packages/nltk/chunk/api.py", line 15, in <module>
from nltk.chunk.util import ChunkScore
File "/Library/Python/2.7/site-packages/nltk/chunk/util.py", line 13, in <module>
from nltk.tag.mapping import map_tag
File "/Library/Python/2.7/site-packages/nltk/tag/__init__.py", line 63, in <module>
from nltk.tag.sequential import (SequentialBackoffTagger, ContextTagger,
File "/Library/Python/2.7/site-packages/nltk/tag/sequential.py", line 25, in <module>
from nltk.classify import NaiveBayesClassifier
File "/Library/Python/2.7/site-packages/nltk/classify/__init__.py", line 98, in <module>
from nltk.classify.textcat import TextCat
File "/Library/Python/2.7/site-packages/nltk/classify/textcat.py", line 47, in <module>
import regex as re
File "/Library/Python/2.7/site-packages/regex.py", line 672, in <module>
_pattern_type = type(_compile("", 0, {}))
File "/Library/Python/2.7/site-packages/regex.py", line 425, in _compile
pattern_locale = _getlocale()[1]
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 562, in getlocale
return _parse_localename(localename)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 475, in _parse_localename
raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: UTF-8