简体   繁体   中英

UnicodeDecodeError when download corpora NLTK with python2.7

i think that i installed nltk packages successively when i typed below sentences i got error. 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? The # -*- coding: utf-8 -*- head comment is only supported in some editors. For all editors should work # coding=<encoding name> . Please read the docs fire more information. 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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM