导入nltk不起作用 [英] import nltk does not work

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

问题描述

因此,我只是从网站上下载了nltk模块并进行了安装.但是,当我在python控制台上运行import nltk时,出现此错误.有谁能够帮我?我已经在网上搜索了此错误,但无济于事.

So I just downloaded nltk module from the website and installed it. But when I run import nltk on the python console, I am getting this error. Can anybody help me? I've searched online for this error but to no avail.

>>> import nltk
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/nltk/__init__.py", line 128, in <module>
    from nltk.chunk import *
  File "/usr/local/lib/python2.7/dist-packages/nltk/chunk/__init__.py", line 157, in <module>
    from nltk.chunk.api import ChunkParserI
  File "/usr/local/lib/python2.7/dist-packages/nltk/chunk/api.py", line 13, in <module>
    from nltk.parse import ParserI
  File "/usr/local/lib/python2.7/dist-packages/nltk/parse/__init__.py", line 79, in <module>
    from nltk.parse.transitionparser import TransitionParser
  File "/usr/local/lib/python2.7/dist-packages/nltk/parse/transitionparser.py", line 21, in <module>
    from sklearn.datasets import load_svmlight_file
  File "/home/jaydeep/.local/lib/python2.7/site-packages/sklearn/__init__.py", line 57, in <module>
    from .base import clone
  File "/home/jaydeep/.local/lib/python2.7/site-packages/sklearn/base.py", line 11, in <module>
    from .utils.fixes import signature
  File "/home/jaydeep/.local/lib/python2.7/site-packages/sklearn/utils/__init__.py", line 10, in <module>
    from .murmurhash import murmurhash3_32
  File "numpy.pxd", line 155, in init sklearn.utils.murmurhash (sklearn/utils/murmurhash.c:5029)
**ValueError: numpy.dtype has the wrong size, try recompiling**

我尝试重新安装numpynltk,但仍然收到相同的错误

I have tried reinstalling both numpy and nltk but I still get the same error

推荐答案

此错误通常是在您安装了较旧版本的numpy时引起的.

This error is typically caused when you have an older version of numpy installed.

尝试通过pip升级:

sudo pip install numpy --upgrade

如果您已经已经安装了较新的numpy 并仍然获得此,则可能您有两个版本的numpy ,并且当您通过python-console访问它时指向旧版本.此处已解决:类似问题

If you have already installed a newer numpy and still get this, its possible that you may have two versions of numpy and when you access it through python-console its pointing to the older version. This is solved here : similar issue

您也可以通过sklearn使用的 openblas/atlas 来获得此信息.按照scikit-learn高级安装:

Your also get this because of openblas/atlas used by sklearn. As per the scikit-learn advanced installation :

使用openblas可以提高某些scikit-learn模块的速度,但是可以 在openblas版本0.2.8-4之前冻结joblib/multiprocessing,因此 除非您知道自己在做什么,否则不建议使用它.

using openblas can give speedups in some scikit-learn modules, but can freeze joblib/multiprocessing prior to openblas version 0.2.8-4, so using it is not recommended unless you know what you’re doing.

如果 确实想使用openblas,那么只需更换几副地图集 命令. 必须删除地图集,否则numpy可能无法正常工作.

If you do want to use openblas, then replacing atlas only requires a couple of commands. Atlas has to be removed, otherwise numpy may not work.

来源

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

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