Reputation: 43
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**
I have tried reinstalling both numpy
and nltk
but I still get the same error
Upvotes: 0
Views: 7926
Reputation: 2275
Recently I had the same issue in Ubuntu. Tried with upgrading numpy, uninstalled scikit-learn. Nothing works. Just restarted the system and got worked.
Upvotes: 1
Reputation: 28199
This error is typically caused when you have an older version of numpy installed.
Try by upgrading it with pip :
sudo pip install numpy --upgrade
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
Your also get this because of openblas/atlas used by sklearn. As per the scikit-learn advanced installation :
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.
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.
Upvotes: 2
Reputation: 43
Never mind. All I had to do was uninstall scikit-learn
and it worked smoothly.
I don't understand why this worked. If anyone could shed some light on this it would be appreciated.
Upvotes: 1