miniforge3 doesn't include sklearn?

I followed this guideline to install tensorflow https://developer.apple.com/metal/tensorflow-plugin/

but sklearn cannot be found so I used conda install sklearn and then somehow sklearn module still cannot be imported.

Here is the outputs when I tried to import sklearn:

(base) (tensorflow-metal) a@A ~ % python

Python 3.9.7 | packaged by conda-forge | (default, Sep 29 2021, 19:24:02) 

[Clang 11.1.0 ] on darwin

Type "help", "copyright", "credits" or "license" for more information.

>>> import sklearn

Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

  File "/Users/a/miniforge3/lib/python3.9/site-packages/sklearn/__init__.py", line 82, in <module>

    from .base import clone

  File "/Users/a/miniforge3/lib/python3.9/site-packages/sklearn/base.py", line 17, in <module>

    from .utils import _IS_32BIT

  File "/Users/a/miniforge3/lib/python3.9/site-packages/sklearn/utils/__init__.py", line 28, in <module>

    from .fixes import np_version, parse_version

  File "/Users/a/miniforge3/lib/python3.9/site-packages/sklearn/utils/fixes.py", line 20, in <module>

    import scipy.stats

  File "/Users/a/miniforge3/lib/python3.9/site-packages/scipy/stats/__init__.py", line 441, in <module>

    from .stats import *

  File "/Users/a/miniforge3/lib/python3.9/site-packages/scipy/stats/stats.py", line 37, in <module>

    from scipy.spatial.distance import cdist

  File "/Users/a/miniforge3/lib/python3.9/site-packages/scipy/spatial/__init__.py", line 98, in <module>

    from .qhull import *

ImportError: dlopen(/Users/a/miniforge3/lib/python3.9/site-packages/scipy/spatial/qhull.cpython-39-darwin.so, 0x0002): Library not loaded: @rpath/liblapack.3.dylib

  Referenced from: /Users/a/miniforge3/lib/python3.9/site-packages/scipy/spatial/qhull.cpython-39-darwin.so

  Reason: tried: '/Users/a/miniforge3/lib/liblapack.3.dylib' (no such file), '/Users/a/miniforge3/lib/liblapack.3.dylib' (no such file), '/Users/a/miniforge3/lib/python3.9/site-packages/scipy/spatial/../../../../liblapack.3.dylib' (no such file), '/Users/a/miniforge3/lib/liblapack.3.dylib' (no such file), '/Users/a/miniforge3/lib/liblapack.3.dylib' (no such file), '/Users/a/miniforge3/lib/python3.9/site-packages/scipy/spatial/../../../../liblapack.3.dylib' (no such file), '/Users/a/miniforge3/lib/liblapack.3.dylib' (no such file), '/Users/a/miniforge3/bin/../lib/liblapack.3.dylib' (no such file), '/Users/a/miniforge3/lib/liblapack.3.dylib' (no such file), '/Users/a/miniforge3/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)

>>> 

some people said sklearn cannot be used in M1 Chip, is it right?

  • tensorflow-macos: 2.6.0
  • tensorflow-metal: 0.2.0
  • macOS: 12.0.1

Many thanks for any help.

Answered by dkjdjdfdskln in 693410022

I followed the official guideline (https://scikit-learn.org/stable/developers/advanced_installation.html), but somehow still cannot work.

so I took almost one day to solve this problem, combining the solutions from: https://github.com/scikit-learn/scikit-learn/issues/19137 and https://github.com/scikit-learn-contrib/hdbscan/issues/457and it works.

python -m pip install --no-cache --no-use-pep517 pythran cython pybind11 gast"==0.4.0"
pyenv rehash
pip install --pre -i https://pypi.anaconda.org/scipy-wheels-nightly/simple scipy
python -m pip install --no-use-pep517 scikit-learn --no-binary :all:

You should use scikit-learn instead.

there has a typo, I installed sklearn by using conda install scikit-learn . sorry for any misleading.

there has a typo, I installed sklearn by using conda install scikit-learn . sorry for any misleading.

Accepted Answer

I followed the official guideline (https://scikit-learn.org/stable/developers/advanced_installation.html), but somehow still cannot work.

so I took almost one day to solve this problem, combining the solutions from: https://github.com/scikit-learn/scikit-learn/issues/19137 and https://github.com/scikit-learn-contrib/hdbscan/issues/457and it works.

python -m pip install --no-cache --no-use-pep517 pythran cython pybind11 gast"==0.4.0"
pyenv rehash
pip install --pre -i https://pypi.anaconda.org/scipy-wheels-nightly/simple scipy
python -m pip install --no-use-pep517 scikit-learn --no-binary :all:
miniforge3 doesn't include sklearn?
 
 
Q