30

Running Ubuntu 11.10 + python2.7...built numpy from source and installed it, but when I go to install it, I get

ImportError: /usr/lib/liblapack.so.3gf: undefined symbol: ATL_chemv

when it tries to import lapack_lite from numpy.linalg. I tried to rebuild lapack from scratch, but it seems to just make

/usr/local/lib/libblas.a
/usr/local/lib/liblapack.a
/usr/local/lib/libtmglib.a

and the .so file. Where does the .so.3gf come from, and how do I fix it?

Saullo G. P. Castro
  • 56,802
  • 26
  • 179
  • 234
Richard Żak
  • 814
  • 1
  • 11
  • 21
  • Did you use `pip install numpy`? Also, any reason why Ubuntu's `python-numpy` package didn't work for you? – Blender Jan 18 '12 at 21:56

4 Answers4

61

I was having the same problem and removing the package libopenblas-base did the trick:

sudo apt-get remove libopenblas-base

As already explained by others, several packages provide incompatible versions of liblapack.so.3gf.

soramimo
  • 1,296
  • 1
  • 13
  • 17
  • 1
    Is there any package who also provides incompatible version of liblapack.so.3gf? I tried removing libopenblas-base, but apt-get couldn't find this package. – João Daniel Jun 29 '12 at 18:36
9

According to some bugreports I see around, you may have more than one provider of BLAS/ATLAS/LAPACK installed, like ATLAS and OpenBLAS/GotoBLAS, that conflict with each other. Have a look on this:

$ ls -l /etc/alternatives/*.so.3gf

and check that all them correspond to the same package (eg. they all point into /usr/lib/atlas-base/)

Ricardo Cárdenes
  • 9,004
  • 1
  • 21
  • 34
  • i have this error when importing numpy as one user, but not as another user. How could this be? – K.-Michael Aye Jan 24 '12 at 11:16
  • Could it be that each of you is importing a different version of NumPy (eg. system-wide vs. a locally compiled one)? If not, an LD_LIBRARY_PATH in someones' environment could be making NumPy to load a different LAPACK. – Ricardo Cárdenes Jan 24 '12 at 11:56
  • 1
    i had this because one user had LD_LIBRARY_PATH set, the other not. And yes, we have a software system that supplies this library and demands to use it's own version. grrrr – K.-Michael Aye Jan 24 '12 at 15:56
  • Good to know you could find it :) – Ricardo Cárdenes Jan 24 '12 at 16:10
  • what should I do if there are more than one? /etc/alternatives/libblas.so.3gf -> /usr/lib/libblas/libblas.so.3 /etc/alternatives/liblapack.so.3gf -> /usr/lib/atlas-base/atlas/liblapack.so.3gf If I remove one or another, apt-get reinstall it – Richard Sep 12 '14 at 13:49
  • @Richard They are different libraries, it's just that a number of packages offer them and they need to match each other. The ideal would be to keep installed only the ones you want. Also, you can use `update-alternatives` from the command line to force a *certain* version of a library to be the one used by the whole system, when there's more than one alternative. – Ricardo Cárdenes Sep 12 '14 at 13:58
  • update-alternatives: error: alternative liblapack.so.3gf cant be secondary from liblapack.so.3: it's a main alternative ; I'm getting this error during the install. Should I use update-alternative to solve the problem? Thanks for your time – Richard Sep 12 '14 at 14:11
  • (I've translated the message from a french error message, I'm sorry if it is inaccurate) – Richard Sep 12 '14 at 14:11
  • I'm not sure about that. I have never seen that message from `update-alternatives`, and I think it's better if you ask a new question (maybe at askubuntu, or here in stackoverflow) about that – Ricardo Cárdenes Sep 12 '14 at 14:28
4

This issue arises when you have libopenblas-base and libatlas3-base installed, but don't have liblapack3 installed. This combination of packages installs conflicting versions of libblas.so (from OpenBLAS) and liblapack.so (from ATLAS).

Solution 1 (my favorite): You can keep both OpenBLAS and ATLAS on your machine if you also install liblapack3.

sudo apt-get install liblapack3

Solution 2: Uninstall ATLAS (this will actually install liblapack3 for you automatically because of some deb package shenanigans)

sudo apt-get uninstall libatlas3-base

Solution 3: Uninstall OpenBLAS

sudo apt-get uninstall libopenblas-base


Bad configuration

$ dpkg -l | grep 'openblas\|atlas\|lapack'
ii  libatlas3-base                                        3.10.1-4                                            amd64        Automatically Tuned Linear Algebra Software, generic shared
ii  libopenblas-base                                      0.2.8-6ubuntu1                                      amd64        Optimized BLAS (linear algebra) library based on GotoBLAS2
$ update-alternatives --get-selections | grep 'blas\|lapack'
libblas.so.3                   auto     /usr/lib/openblas-base/libblas.so.3
liblapack.so.3                 auto     /usr/lib/atlas-base/atlas/liblapack.so.3
$ python -c 'import numpy'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/numpy/__init__.py", line 153, in <module>
    from . import add_newdocs
  File "/usr/lib/python2.7/dist-packages/numpy/add_newdocs.py", line 13, in <module>
    from numpy.lib import add_newdoc
  File "/usr/lib/python2.7/dist-packages/numpy/lib/__init__.py", line 18, in <module>
    from .polynomial import *
  File "/usr/lib/python2.7/dist-packages/numpy/lib/polynomial.py", line 19, in <module>
    from numpy.linalg import eigvals, lstsq, inv
  File "/usr/lib/python2.7/dist-packages/numpy/linalg/__init__.py", line 50, in <module>
    from .linalg import *
  File "/usr/lib/python2.7/dist-packages/numpy/linalg/linalg.py", line 29, in <module>
    from numpy.linalg import lapack_lite, _umath_linalg
ImportError: /usr/lib/liblapack.so.3: undefined symbol: ATL_chemv

Solution 1

$ dpkg -l | grep 'openblas\|atlas\|lapack'
ii  libatlas3-base                                        3.10.1-4                                            amd64        Automatically Tuned Linear Algebra Software, generic shared
ii  liblapack3                                            3.5.0-2ubuntu1                                      amd64        Library of linear algebra routines 3 - shared version
ii  libopenblas-base                                      0.2.8-6ubuntu1                                      amd64        Optimized BLAS (linear algebra) library based on GotoBLAS2
$ update-alternatives --get-selections | grep 'blas\|lapack'
libblas.so.3                   auto     /usr/lib/openblas-base/libblas.so.3
liblapack.so.3                 auto     /usr/lib/lapack/liblapack.so.3
$ python -c 'import numpy'

Solution 2

$ dpkg -l | grep 'openblas\|atlas\|lapack'
ii  liblapack3                                            3.5.0-2ubuntu1                                      amd64        Library of linear algebra routines 3 - shared version
ii  libopenblas-base                                      0.2.8-6ubuntu1                                      amd64        Optimized BLAS (linear algebra) library based on GotoBLAS2
$ update-alternatives --get-selections | grep 'blas\|lapack'
libblas.so.3                   auto     /usr/lib/openblas-base/libblas.so.3
liblapack.so.3                 auto     /usr/lib/lapack/liblapack.so.3
$ python -c 'import numpy'

Solution 3

$ dpkg -l | grep 'openblas\|atlas\|lapack'
ii  libatlas3-base                                        3.10.1-4                                            amd64        Automatically Tuned Linear Algebra Software, generic shared
$ update-alternatives --get-selections | grep 'blas\|lapack'
libblas.so.3                   auto     /usr/lib/atlas-base/atlas/libblas.so.3
liblapack.so.3                 auto     /usr/lib/atlas-base/atlas/liblapack.so.3
$ python -c 'import numpy'
Luke Yeager
  • 1,400
  • 1
  • 17
  • 30
1

Try checking the LD_LIBRARY_PATH. You might point in there to another version of that library that does not support the symbol the numpy call needs. I had the same situation on my Mac.

But be careful, the problem might not be visible directly, because one library could link to the next using the LD_LIBRARY_PATH.

You can check if you see a difference in the following command with and without the LD_LIBRARY_PATH set (to remove temporarily for the active shell: unset LD_LIBRARY_PATH):

ldd /usr/lib/liblapack.so.3gf

In my case, libraries provided by the ISIS software system clashed with the onboard libraries that numpy requires.

K.-Michael Aye
  • 5,465
  • 6
  • 44
  • 56