The TransportMap support team will be happy to help you out with questions ranging from theory on transport maps, to the installation and usage of the software TransportMaps.

import error and installation of scikit-sparse

0 votes

Hi there,

I have installed TransportMaps on Mac (Mojave + Anaconda Python) but when I try to import it in Jupyter I get the error below.

I suspect the problem is with my installation: one of the errors in my installation was that scikit-sparse could not be installed due to "cholmod.h file not found". I solved that error via using "conda install -c conda-forge scikit-sparse" which apparently worked for installation of TM. (this solution was suggested here: )

Now I see that the TM import error (at the bottom of log) relates to sksparse and cholmod.

Do you have any suggestions on how to get past this?





ImportError                               Traceback (most recent call last)
<ipython-input-4-938b228a6841> in <module>()
----> 1 import TransportMaps as tm

/anaconda3/lib/python3.6/site-packages/TransportMaps-2.0b2-py3.6.egg/TransportMaps/Algorithms/SparsityIdentification/ in <module>()
      1 from . import SparsityIdentificationNonGaussian
      2 from .SparsityIdentificationNonGaussian import *
----> 3 from . import NodeOrdering
      4 from .NodeOrdering import *
      5 from . import GeneralizedPrecision

/anaconda3/lib/python3.6/site-packages/TransportMaps-2.0b2-py3.6.egg/TransportMaps/Algorithms/SparsityIdentification/ in <module>()
      3 import copy
----> 5 from sksparse.cholmod import cholesky
      6 from scipy.sparse import csc_matrix
      7 import itertools

ImportError: dlopen(/anaconda3/lib/python3.6/site-packages/sksparse/, 2): Library not loaded: @rpath/libcholmod.3.0.11.dylib
  Referenced from: /anaconda3/lib/python3.6/site-packages/sksparse/
  Reason: image not found
asked Nov 9, 2018 in installation by HassanAr (13 points)

2 Answers

0 votes

Hi, thank you for reporting the problem.

Yes, I run into a similar problem myself some time ago on Linux but I had not time to update the installation instructions. On Linux

apt install libsuitesparse-dev

solves the problem.

I don't have direct experience on Mac (I'll get a Mac later and try), but could you try to simply run a python terminal and perform that import line?

from sksparse.cholmod import cholesky

It seems the installation was succesful but you are still not able to import.

I'll ask one of my colleagues who uses TransportMap on Mac to pictch in.

answered Nov 9, 2018 by dabi (307 points)
+1 vote

Hi Hassan, 

Thank you very much for your question! 

To follow up on the previous suggestion, I think you may be missing the sparse Cholesky factorization library,  CHOMOD. The library is used by scikit-sparse and I believe it does not come with the conda-forge package. The easiest approach may be to download the suitesparse package that contains several sparse matrix methods, including CHOLMOD, and to reinstall scikit-sparse. I've tested it on Mojave with Anaconda Python 3.6 and it seems to be working.

Please let us know if this fixes the import error on your end, and if not we are glad to investigate further!

answered Nov 10, 2018 by Ricardo (12 points)
Thank you dabi and Ricardo for the suggestions!

I suspect Ricardo's solution would work, bc before it was posted here I tried something similar and it went thru: after I got the import error, I removed the conda-forge package and then reinstalled scikit-sparse using plain pip - this time it worked (unlike before where it could not make th wheel). Then TransportMap worked.

I also tried installing suitsparse before that, but It was unsuccessful (it had trouble installing METIS and the instructions in the suitsparse's readme was not clear to me ... )