Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error importing scipy.sparse._sparsetools

Tags:

python

scipy

I'm working on a macbook pro trying to use the gensim package to do Word2Vec. I had used the model earlier in the week, but when I tried to resume using it, I was given an error regarding loading scipy. I tried loading only the specific model echoing the error message, and this is the same output:

>>> import scipy.sparse._sparsetools
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "//anaconda/lib/python2.7/site-packages/scipy/sparse/__init__.py", line 213, in <module>
    from .csr import *
  File "//anaconda/lib/python2.7/site-packages/scipy/sparse/csr.py", line 13, in <module>
    from ._sparsetools import csr_tocsc, csr_tobsr, csr_count_blocks, \
ImportError: dlopen(//anaconda/lib/python2.7/site-packages/scipy/sparse/_sparsetools.so, 2): Symbol not found: __ZNSs4_Rep20_S_empty_rep_storageE
  Referenced from: //anaconda/lib/python2.7/site-packages/scipy/sparse/_sparsetools.so
  Expected in: dynamic lookup

I intall everything via pip, so nothing was specifically built on this mac. Any advice would be most appreciated.

System details:

  • Python 2.7.8 |Anaconda 2.1.0 (x86_64)| (default, Aug 21 2014, 15:21:46)
  • Mac OSX, Yosemite (10.10.5)
  • scipy 0.14.0
like image 675
j.a.gartner Avatar asked Sep 17 '15 00:09

j.a.gartner


1 Answers

Your issue is likely caused by a linking problem described in this github issue.

Since you are already using anaconda, probably the best strategy for you is to use compiled binaries instead of trying to compile with pip yourself.

The only two things you have to do is:

pip uninstall scipy
conda install scipy
like image 183
cel Avatar answered Oct 23 '22 05:10

cel