[英]UnicodeDecodeError when download corpora NLTK with python2.7
i think that i installed nltk packages successively when i typed below sentences i got error. 我认为我输入nltk包时,我输入下面的句子我有错误。 is that error from installing?
是安装错误? or coding?
还是编码?
#-*- coding: utf-8 -*-
import nltk
nltk.download()
Traceback (most recent call last):
File "C:/Lab/crawling/crawling_practice.py", line 2, in <module>
import nltk
File "C:\Anaconda2\lib\nltk\__init__.py", line 128, in <module>
from nltk.chunk import *
File "C:\Anaconda2\lib\nltk\chunk\__init__.py", line 155, in <module>
from nltk.data import load
File "C:\Anaconda2\lib\nltk\data.py", line 77, in <module>
if 'APPENGINE_RUNTIME' not in os.environ and os.path.expanduser('~/') != '~/':
File "C:\Anaconda2\lib\ntpath.py", line 311, in expanduser
return userhome + path[i:]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc1 in position 9: ordinal not in range(128)
What Python editor are you using? 您使用的是什么Python编辑器? The
# -*- coding: utf-8 -*-
head comment is only supported in some editors. # -*- coding: utf-8 -*-
head注释仅在某些编辑器中受支持。 For all editors should work # coding=<encoding name>
. 对于所有编辑应该工作
# coding=<encoding name>
。 Please read the docs fire more information. 请阅读文档了解更多信息。 https://www.python.org/dev/peps/pep-0263 .
https://www.python.org/dev/peps/pep-0263 。 What also could be, is that the filepath where nltk tries to download itself or your username contains any Unicode characters (see last traceback line)
也可能是,nltk尝试下载自己的文件路径或您的用户名包含任何Unicode字符(请参阅最后的追溯行)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.