Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import numpy fails because libopenblas.dylib does not load #14165

Closed
sprague252 opened this issue Jul 30, 2019 · 7 comments
Closed

import numpy fails because libopenblas.dylib does not load #14165

sprague252 opened this issue Jul 30, 2019 · 7 comments
Labels
32 - Installation Problems installing or compiling NumPy

Comments

@sprague252
Copy link

When I try to import numpy, it fails with the following error message.

Original error was: dlopen(/opt/anaconda3/lib/python3.7/site-packages/numpy/core/_multiarray_umath.cpython-37m-darwin.so, 2): Library not loaded: @rpath/libopenblas.dylib
  Referenced from: /opt/anaconda3/lib/python3.7/site-packages/numpy/core/_multiarray_umath.cpython-37m-darwin.so
  Reason: image not found

I get this error on a fresh anaconda install from the conda-forge repo on Mac OS X. Numpy has worked on this computer before my most recent update.

Note that my computer is a MacBook Pro running Mac OS X 10.14.6, but I get the same error on an older Mac Pro running Mac OS X 10.13.6.

Reproducing code example:

import numpy as np

Error message:

ImportError Traceback (most recent call last)
/opt/anaconda3/lib/python3.7/site-packages/numpy/core/init.py in
39 try:
---> 40 from . import multiarray
41 except ImportError as exc:

/opt/anaconda3/lib/python3.7/site-packages/numpy/core/multiarray.py in
11
---> 12 from . import overrides
13 from . import _multiarray_umath

/opt/anaconda3/lib/python3.7/site-packages/numpy/core/overrides.py in
5
----> 6 from numpy.core._multiarray_umath import (
7 add_docstring, implement_array_function, _get_implementing_args)

ImportError: dlopen(/opt/anaconda3/lib/python3.7/site-packages/numpy/core/_multiarray_umath.cpython-37m-darwin.so, 2): Library not loaded: @rpath/libopenblas.dylib
Referenced from: /opt/anaconda3/lib/python3.7/site-packages/numpy/core/_multiarray_umath.cpython-37m-darwin.so
Reason: image not found

During handling of the above exception, another exception occurred:

ImportError Traceback (most recent call last)
in
----> 1 import numpy as np

/opt/anaconda3/lib/python3.7/site-packages/numpy/init.py in
140 from . import _distributor_init
141
--> 142 from . import core
143 from .core import *
144 from . import compat

/opt/anaconda3/lib/python3.7/site-packages/numpy/core/init.py in
69 Original error was: %s
70 """ % (sys.executable, exc)
---> 71 raise ImportError(msg)
72 finally:
73 for envkey in env_added:

ImportError:

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
Here is how to proceed:

  • If you're working with a numpy git repository, try git clean -xdf
    (removes all files not under version control) and rebuild numpy.
  • If you are simply trying to use the numpy version that you have installed:
    your installation is broken - please reinstall numpy.
  • If you have already reinstalled and that did not fix the problem, then:
    1. Check that you are using the Python you expect (you're using /opt/anaconda3/bin/python),
      and that you have no directories in your PATH or PYTHONPATH that can
      interfere with the Python and numpy versions you're trying to use.

    2. If (1) looks fine, you can open a new issue at
      https://github.com/numpy/numpy/issues. Please include details on:

      • how you installed Python
      • how you installed numpy
      • your operating system
      • whether or not you have multiple versions of Python installed
      • if you built from source, your compiler versions and ideally a build log

      Note: this error has many possible causes, so please don't comment on
      an existing issue about this - open a new one instead.

Original error was: dlopen(/opt/anaconda3/lib/python3.7/site-packages/numpy/core/_multiarray_umath.cpython-37m-darwin.so, 2): Library not loaded: @rpath/libopenblas.dylib
Referenced from: /opt/anaconda3/lib/python3.7/site-packages/numpy/core/_multiarray_umath.cpython-37m-darwin.so
Reason: image not found

Numpy/Python version information:

Note that importing numpy causes the error, so I cannot do an import numpy; print(numpy.__version__). Running conda list gives the numpy version as 1.16.4 and the build as py36h926163e_0.

import sys; print(sys.version)                                          
3.6.7 | packaged by conda-forge | (default, Jul  2 2019, 02:07:37) 
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)]
@sprague252
Copy link
Author

I tried some of my other conda environments, and I can import numpy in all of the environments that have a version of openblas prior to 0.3.6. I rolled back my openblas version in the environment that produced the error to 0.3.3 with numpy 1.16.4, and there is no longer a problem importing numpy. It seems like the problem is due to something in openblas 0.3.6.

@rgommers rgommers added the 32 - Installation Problems installing or compiling NumPy label Dec 3, 2019
@jriehl
Copy link

jriehl commented Jan 7, 2020

FWIW, libopenblas 0.3.6 names the dynamic library libopenblas.0.dylib. Creating a symlink from libopenblas.dylib to libopenblas.0.dylib is another workaround.

@SirPhemmiey
Copy link

Hey @jriehl, how do you mean, please?

@samuel-72
Copy link

I faced this issue while trying to install numpy 1.18.1 in virtualenv with python 3.7.6. The problem was that I did not have numpy installed in the base os. Once I installed numpy in the base mac OS and reinstalled numpy in the virtualenv it worked.

@sprague252
Copy link
Author

I lost track of this issue some time ago. Sorry. Some time ago I made a fresh install of Anaconda with the default configuration, and I no longer have the problem. This default anaconda install does not include openblas. Here is my version information:

import sys; print(sys.version)
3.7.6 | packaged by conda-forge | (default, Jan  7 2020, 22:05:27)
[Clang 9.0.1 ]

import numpy; print(numpy.__version__)
1.18.1

@zezhong-zhang
Copy link

This also occurs to me with python 3.7.8 and numpy 1.19.1 and not fully resolved yet.

I tried linking libopenblas.dylib to libopenblas.0.dylib (which itself is linked to the current libopenblas, for instance, libopenblasp-r0.3.10.dylib) but still does not work.

The only way I get it working is to conda install blas=1.1 instead of current 2.x. Many thanks if you have any suggestions.
The output of conda list blas

Name                    Version                   Build  Channel
blas                      1.1                    openblas    conda-forge
libblas                   3.8.0               17_openblas    conda-forge
libcblas                  3.8.0               17_openblas    conda-forge
libopenblas               0.3.10          openmp_h63d9170_4    conda-forge

@mattip
Copy link
Member

mattip commented Sep 29, 2020

@zezhong-zhang please open a new issue, this is closed. Be sure to read https://numpy.org/devdocs/user/troubleshooting-importerror.html and if that does not help, report the entire error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
32 - Installation Problems installing or compiling NumPy
Projects
None yet
Development

No branches or pull requests

7 participants