The Wayback Machine - https://web.archive.org/web/20220225204739/https://github.com/scikit-learn/scikit-learn/issues/22522
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

apple silicon m1 can't importing sklearn package. #22522

Closed
Mecil9 opened this issue Feb 17, 2022 · 3 comments
Closed

apple silicon m1 can't importing sklearn package. #22522

Mecil9 opened this issue Feb 17, 2022 · 3 comments
Labels

Comments

@Mecil9
Copy link

@Mecil9 Mecil9 commented Feb 17, 2022

I have been finished install Tensorflow env step by step from "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)

image

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
@thomasjpfan
Copy link
Member

@thomasjpfan thomasjpfan commented Feb 17, 2022

From your error message, it looks like the SciPy import failed. Can you see if the following fails?

from scipy.spatial.distance import cdist

On my M1 machine, the following works:

# Create new environment
conda create -n tensorflow python=3.9
conda activate tensorflow

# Install tensorflow + scikit-learn
conda install -c apple tensorflow-deps
python -m pip install tensorflow-macos
python -m pip install tensorflow-metal
python -m pip install scikit-learn

# Check import works
python -c "import sklearn"

@glemaitre
Copy link
Contributor

@glemaitre glemaitre commented Feb 17, 2022

As well on my M1.

@Mecil9
Copy link
Author

@Mecil9 Mecil9 commented Feb 21, 2022

As well on my M1.

it's working, after i reinstall

conda install -c apple tensorflow-deps==2.8.0

conda reinstall numpy , scipy, scikit-learn
Machine learning extensions are not well supported on Apple silicon.
And for opencv, I haven't figured it out yet!
M1's configuration environment is too complex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants