0

Whenever I try doing import scipy.spatial.distance in a jupyter lab notebook (local installation), I get the following error. However, import scipy works fine, and running pip show scipy in the terminal tells me I have scipy 1.10.1 installed. This issue also manifests itself when I try to install scikit-learn, with the error ImportError: scipy is not installed. scikit-learn requires scipy >= 1.3.2.. This confuses me even more because pip show scipy tells me scipy is installed. I have already tried running brew info openblas and using all the flags that appear there. Maybe it's an issue with where my scipy is installed; my computer can't seem to access it for some reason? I'd really appreciate some help, thanks! Fyi, I'm using macOS Big Sur with an M1 chip on a 2020 Macbook Air.

import scipy.spatial.distance
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
/var/folders/td/dtym05z13119cjklqb5tyd040000gn/T/ipykernel_23242/2695475963.py in <module>
----> 1 import scipy.spatial.distance

~/opt/anaconda3/lib/python3.8/site-packages/scipy/spatial/__init__.py in <module>
    103 """
    104 
--> 105 from ._kdtree import *
    106 from ._ckdtree import *
    107 from ._qhull import *

~/opt/anaconda3/lib/python3.8/site-packages/scipy/spatial/_kdtree.py in <module>
      2 # Released under the scipy license
      3 import numpy as np
----> 4 from ._ckdtree import cKDTree, cKDTreeNode
      5 
      6 __all__ = ['minkowski_distance_p', 'minkowski_distance',

_ckdtree.pyx in init scipy.spatial._ckdtree()

~/opt/anaconda3/lib/python3.8/site-packages/scipy/sparse/__init__.py in <module>
    281 
    282 # For backward compatibility with v0.19.
--> 283 from . import csgraph
    284 
    285 # Deprecated namespaces, to be removed in v2.0.0

~/opt/anaconda3/lib/python3.8/site-packages/scipy/sparse/csgraph/__init__.py in <module>
    183            'NegativeCycleError']
    184 
--> 185 from ._laplacian import laplacian
    186 from ._shortest_path import (
    187     shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson,

~/opt/anaconda3/lib/python3.8/site-packages/scipy/sparse/csgraph/_laplacian.py in <module>
      5 import numpy as np
      6 from scipy.sparse import isspmatrix
----> 7 from scipy.sparse.linalg import LinearOperator
      8 
      9 

~/opt/anaconda3/lib/python3.8/site-packages/scipy/sparse/linalg/__init__.py in <module>
    118 """
    119 
--> 120 from ._isolve import *
    121 from ._dsolve import *
    122 from ._interface import *

~/opt/anaconda3/lib/python3.8/site-packages/scipy/sparse/linalg/_isolve/__init__.py in <module>
      2 
      3 #from info import __doc__
----> 4 from .iterative import *
      5 from .minres import minres
      6 from .lgmres import lgmres

~/opt/anaconda3/lib/python3.8/site-packages/scipy/sparse/linalg/_isolve/iterative.py in <module>
      7 import numpy as np
      8 
----> 9 from . import _iterative
     10 
     11 from scipy.sparse.linalg._interface import LinearOperator

ImportError: dlopen(/Users/rohanjha/opt/anaconda3/lib/python3.8/site-packages/scipy/sparse/linalg/_isolve/_iterative.cpython-38-darwin.so, 2): Library not loaded: @rpath/libopenblas.0.dylib
  Referenced from: /Users/rohanjha/opt/anaconda3/lib/python3.8/site-packages/scipy/sparse/linalg/_isolve/_iterative.cpython-38-darwin.so
  Reason: image not found

0 Answers0