Apple m1 pro max install Tensorflow, can't importing scikit-learn

I have been finished install Tensorflow env step by step from "https://developer.apple.com/metal/tensorflow-plugin/" https://developer.apple.com/metal/Tensorflow-plugin/ Tf is working! but when i import sklearn package, have an error message like this:

ImportError: dlopen(/Users/mecilmeng/miniforge3/envs/tf/lib/python3.9/site-packages/scipy/spatial/qhull.cpython-39-darwin.so, 0x0002): Library not loaded: @rpath/liblapack.3.dylib
  Referenced from: /Users/mecilmeng/miniforge3/envs/tf/lib/python3.9/site-packages/scipy/spatial/qhull.cpython-39-darwin.so
  Reason: tried: '/Users/mecilmeng/miniforge3/envs/tf/lib/liblapack.3.dylib' (no such file), '/Users/mecilmeng/miniforge3/envs/tf/lib/liblapack.3.dylib' (no such file), '/Users/mecilmeng/miniforge3/envs/tf/lib/python3.9/site-packages/scipy/spatial/../../../../liblapack.3.dylib' (no such file), '/Users/mecilmeng/miniforge3/envs/tf/lib/liblapack.3.dylib' (no such file), '/Users/mecilmeng/miniforge3/envs/tf/lib/liblapack.3.dylib' (no such file), '/Users/mecilmeng/miniforge3/envs/tf/lib/python3.9/site-packages/scipy/spatial/../../../../liblapack.3.dylib' (no such file), '/Users/mecilmeng/miniforge3/envs/tf/bin/../lib/liblapack.3.dylib' (no such file), '/Users/mecilmeng/miniforge3/envs/tf/bin/../lib/liblapack.3.dylib' (no such file), '/usr/local/lib/liblapack.3.dylib' (no such file), '/usr/lib/liblapack.3.dylib' (no such file)

How to fix it?


pip list

Package                  Version
------------------------ -------------------
absl-py                  0.10.0
aiohttp                  3.8.1
aiosignal                1.2.0
anyio                    3.5.0
appnope                  0.1.2
argon2-cffi              20.1.0
astunparse               1.6.3
async-generator          1.10
async-timeout            4.0.1
attrs                    21.4.0
Babel                    2.9.1
backcall                 0.2.0
beniget                  0.3.0
bleach                   4.1.0
blinker                  1.4
Bottleneck               1.3.2
brotlipy                 0.7.0
cached-property          1.5.2
cachetools               4.2.2
certifi                  2021.10.8
cffi                     1.15.0
charset-normalizer       2.0.4
click                    8.0.3
cryptography             3.4.7
cycler                   0.11.0
Cython                   0.29.28
debugpy                  1.5.1
decorator                5.1.1
defusedxml               0.7.1
dill                     0.3.4
entrypoints              0.3
flatbuffers              2.0
fonttools                4.25.0
frozenlist               1.2.0
gast                     0.4.0
google-auth              1.33.0
google-auth-oauthlib     0.4.1
google-pasta             0.2.0
googleapis-common-protos 1.54.0
grpcio                   1.42.0
h5py                     3.1.0
idna                     3.3
importlib-metadata       4.8.2
ipykernel                6.4.1
ipython                  7.31.1
ipython-genutils         0.2.0
jedi                     0.18.1
Jinja2                   3.0.2
joblib                   1.1.0
json5                    0.9.6
jsonschema               3.2.0
jupyter-client           7.1.2
jupyter-core             4.9.1
jupyter-server           1.13.5
jupyterlab               3.2.1
jupyterlab-pygments      0.1.2
jupyterlab-server        2.10.3
keras                    2.8.0
Keras-Preprocessing      1.1.2
kiwisolver               1.3.1
libclang                 13.0.0
Markdown                 3.3.4
MarkupSafe               2.0.1
matplotlib               3.5.0
matplotlib-inline        0.1.2
mistune                  0.8.4
multidict                5.2.0
munkres                  1.1.4
nbclassic                0.2.6
nbclient                 0.5.3
nbconvert                6.3.0
nbformat                 5.1.3
nest-asyncio             1.5.1
networkx                 2.6.3
notebook                 6.4.6
numexpr                  2.8.1
numpy                    1.22.2
oauthlib                 3.1.1
opencv-python            4.5.5.62
opt-einsum               3.3.0
packaging                21.3
pandas                   1.3.5
pandocfilters            1.5.0
parso                    0.8.3
pexpect                  4.8.0
pickleshare              0.7.5
Pillow                   9.0.1
pip                      21.2.4
ply                      3.11
prometheus-client        0.13.1
promise                  2.3
prompt-toolkit           3.0.20
protobuf                 3.19.1
ptyprocess               0.7.0
pyasn1                   0.4.8
pyasn1-modules           0.2.8
pybind11                 2.9.1
pycparser                2.21
Pygments                 2.11.2
PyJWT                    2.1.0
pyOpenSSL                21.0.0
pyparsing                3.0.4
pyrsistent               0.18.0
PySocks                  1.7.1
python-dateutil          2.8.2
pythran                  0.9.11
pytz                     2021.3
pyzmq                    22.3.0
requests                 2.27.1
requests-oauthlib        1.3.0
rsa                      4.7.2
scikit-learn             1.0.2
scipy                    1.7.1
Send2Trash               1.8.0
setuptools               58.0.4
six                      1.15.0
sklearn                  0.0
sniffio                  1.2.0
tensorboard              2.8.0
tensorboard-data-server  0.6.1
tensorboard-plugin-wit   1.6.0
tensorflow-datasets      4.5.2
tensorflow-macos         2.8.0
tensorflow-metadata      1.6.0
tensorflow-metal         0.3.0
termcolor                1.1.0
terminado                0.13.1
testpath                 0.5.0
tf-estimator-nightly     2.8.0.dev2021122109
threadpoolctl            2.2.0
tornado                  6.1
tqdm                     4.62.3
traitlets                5.1.1
typing-extensions        3.7.4.3
urllib3                  1.26.8
wcwidth                  0.2.5
webencodings             0.5.1
websocket-client         0.58.0
Werkzeug                 2.0.2
wheel                    0.35.1
wrapt                    1.12.1
yarl                     1.6.3
zipp                     3.7.0

Replies

Hi,

Can you try:

conda install scikit-learn
  • ye! I use “conda install scikit-learn”, then finished it!

    throw alert message: ImportError:

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

    Importing the numpy C-extensions failed. This error can happen for many reasons, often due to issues with your setup or how NumPy was installed.

    We have compiled some common reasons and troubleshooting tips at:

    https://numpy.org/devdocs/user/troubleshooting-importerror.html

    Please note and check the following:

    The Python version is: Python3.9 from "/Users/mecilmeng/miniforge3/envs/tf/bin/python"The NumPy version is: "1.19.5"

    and make sure that they are the versions you expect. Please carefully study the documentation linked above for further help.

  • Seems like the numpy version mismatch with scikit-learn. Can you create a new Conda env and install: conda install -c apple tensorflow-deps==2.8.0 conda install scikit-learn

    After that I was able to : `>>> from sklearn import datasets

     `
Add a Comment