Python(nltk) - UnicodeDecodeError:'ascii'编解码器无法解码字节 [英] Python (nltk) - UnicodeDecodeError: 'ascii' codec can't decode byte
问题描述
我是NLTK的新手。我收到这个错误,我搜索了编码/解码,特别是UnicodeDecodeError,但这个错误似乎特定于NLTK源代码。
I'm new to NLTK. I'm getting this error and I've searched around for encoding/decoding and specifically the UnicodeDecodeError but this error seems specific to the NLTK source code.
这里的错误:
Traceback (most recent call last):
File "A:\Python\Projects\Test\main.py", line 2, in <module>
print(pos_tag(word_tokenize("John's big idea isn't all that bad.")))
File "A:\Python\Python\lib\site-packages\nltk\tag\__init__.py", line 100, in pos_tag
tagger = load(_POS_TAGGER)
File "A:\Python\Python\lib\site-packages\nltk\data.py", line 779, in load
resource_val = pickle.load(opened_resource)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xcb in position 0: ordinal not in range(128)
如何解决这个错误?
什么原因导致错误:
How do I go around fixing this error?
Here's what causes the error:
from nltk import pos_tag, word_tokenize
print(pos_tag(word_tokenize("John's big idea isn't all that bad.")))
推荐答案
I有同样的问题。我在Windows 7中使用Python 3.4。
I had the same problem with you. I use Python 3.4 in Windows 7.
我安装了nltk-3.0.0.win32.exe(从此处)。但是当我安装了nltk-3.0a4.win32.exe(从这里),我的问题与nltk.pos_tag解决了。检查它。
I had installed the "nltk-3.0.0.win32.exe" (from here). But when i installed the "nltk-3.0a4.win32.exe" (from here), my problem with nltk.pos_tag was solved. Check it.
编辑:如果第二个链接无效,您可以查看此处。
If the second link doesn't work, you can look here.
这篇关于Python(nltk) - UnicodeDecodeError:'ascii'编解码器无法解码字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!