NLTK导入错误 [英] NLTK import error

查看:1052
本文介绍了NLTK导入错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的Python和NLTK。我一直在试图找到一个解决我的问题,但还没有找到一个尚未与希望有人能帮助我。

I'm new to Python and NLTK. I've been trying to find a solution to my problem but have not found one yet and was hoping someone could help me.

目前,我正在运行64位的Windows 8,我紧跟在NLTK网站的指令( HTTP: //www.nltk.org/install.html )。我可能已经安装了64位版本的Python摆在首位,但已删除并重新安装32位版本的Python。现在,我有以下问题:

I'm currently running 64bit Windows 8. I've followed the instruction in the NLTK website (http://www.nltk.org/install.html). I might have installed a 64bit version Python in the first place but have removed it and reinstall 32bit version Python. Now I'm having the following problem:

Python 2.7.9 (default, Dec 10 2014, 12:24:55) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import nltk

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import nltk
  File "C:\Python27\lib\site-packages\nltk\__init__.py", line 117, in <module>
from nltk.align import *
  File "C:\Python27\lib\site-packages\nltk\align\__init__.py", line 15, in <module>
from nltk.align.ibm1 import IBMModel1
  File "C:\Python27\lib\site-packages\nltk\align\ibm1.py", line 18, in <module>
    from nltk.corpus import comtrans
  File "C:\Python27\lib\site-packages\nltk\corpus\__init__.py", line 64, in <module>
    from nltk.tokenize import RegexpTokenizer
  File "C:\Python27\lib\site-packages\nltk\tokenize\__init__.py", line 62, in <module>
    from nltk.data              import load
  File "C:\Python27\lib\site-packages\nltk\data.py", line 74, in <module>
    if os.path.expanduser('~/') != '~/':
  File "C:\Python27\lib\ntpath.py", line 310, in expanduser
    return userhome + path[i:]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xac in position 9: ordinal not in range(128)
>>> 

任何想法?

推荐答案

我解决这个问题,通过改变我的操作系统区域设置不统一code程序:

I solve this by changing my operating system locale for non-Unicode programs:

1 - 进入控制面板

1 – Go to Control Panel

2 - 点击时钟,语言和区域

2 – Click "Clock, Language and Region"

3 - 点击区域和语言选项

3 – Click "Regional and Language Options"

4 - 下围棋管理选项卡

4 – Go under "Administrative" tab

5 - 当前系统的语言环境(非统一code)显示,改变它,点击更改系统区域设置

5 – current system locale (for non-Unicode) is displayed, to change it click "Change system locale"

6 - 然后,只需选择英语!重新启动后,大功告成了!

6 – Then just choose English! After a reboot, done!

这篇关于NLTK导入错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆