1

I am getting a segmentation fault while trying to import nltk on a debian machine.

Here's the python verbose output :-

>>> import nltk
....
....

import scipy.linalg.blas # precompiled from /usr/local/lib/python2.7/dist-packages/scipy/linalg/blas.pyc
# trying /usr/local/lib/python2.7/dist-packages/scipy/linalg/_fblas.so
dlopen("/usr/local/lib/python2.7/dist-packages/scipy/linalg/_fblas.so", 2);
Segmentation fault

Any suggestions ? I have tried uninstalling and reinstalling scipy followed by nltk.

thanks, Amit

Amit Gupta
  • 451
  • 5
  • 18
  • I am just calling the import command. My python version is 2.7.3. How do I switch to ctypes ? – Amit Gupta Oct 08 '14 at 21:03
  • I think it's because of the library fblas, because it works fine on other machines on my cluster which don't have this library installed. – Amit Gupta Oct 08 '14 at 21:04
  • No, I am running python in verbose mode. I am just calling import nltk. – Amit Gupta Oct 08 '14 at 21:05
  • Sorry, disregard the comment about `dlopen`. From the output it was unclear. – Michael Petch Oct 08 '14 at 21:13
  • I have a Debian Wheezy system here running Python 2.7.3 `(default, Mar 13 2014, 11:03:55)`. I did a `pip install nltk`. I then ran Python (2.7.3), and was successful doing `import nltk` – Michael Petch Oct 08 '14 at 21:17
  • Yes, it used to work till I installed blas library I think. But, I don't know how to debug this further. – Amit Gupta Oct 08 '14 at 21:21
  • How did yo install the blas library? – Michael Petch Oct 08 '14 at 21:22
  • sudo apt-get install gfortran libopenblas-dev liblapack-dev – Amit Gupta Oct 08 '14 at 21:56
  • as per this link http://stackoverflow.com/questions/7496547/python-scipy-needs-blas – Amit Gupta Oct 08 '14 at 21:56
  • I had to ask because if I use Debian Wheezy's Scipy, install libblas per those instructions and import nltk there are no issues. I assume you are using a Debian version of Scipy and not one that was built from source? As it stands it has to be something environmental. Something else interfering, like something else on the `path` etc. – Michael Petch Oct 08 '14 at 22:03
  • removed blas for now...seems to work fine now...hoping I won't need blas for sometime – Amit Gupta Oct 14 '14 at 14:06

1 Answers1

2

I had the same problem. I uninstalled scipy and nltk, then reinstalled nltk only.

pip uninstall scipy
pip uninstall nltk
pip install --no-cache-dir nltk

python
import nltk
nltk.download()

works.
However, the problem came back when I reinstalled scipy... The solution for me was to uninstall both packages using pip and conda (conda uninstall nltk), then reinstall scipy using conda and nltk using pip. This combination worked for me, I'm not exactly sure why buit the reason was probably a faulty prior installation of nltk in anaconda.

Shani Shalgi
  • 617
  • 1
  • 6
  • 19
  • You may have ended up installing a different version of scipy with conda than pip was trying to install--I had a similar issue where installing a different version of scipy solved the problem. – Featherlegs Sep 28 '16 at 20:08