简体   繁体   English

安装 sklearn 时 Pip 挂起并出错

[英]Pip hangs and errors out when installing sklearn

I just got a new M1 Max MacBook Pro and I'm trying to install some essential python libraries to it.我刚买了一台新的 M1 Max MacBook Pro,我正在尝试为它安装一些基本的 Python 库。 Pandas installed just fine but sklearn hangs really bad and then gives a massive error. Pandas 安装得很好,但 sklearn 挂起非常糟糕,然后给出了一个巨大的错误。

What I've tried: pip3 install sklearn and pip install sklearn我试过的: pip3 install sklearnpip install sklearn
The error message is UNBELIEVABLY long.错误消息长得令人难以置信。 Here is the last seemingly parsable part of it:这是最后一个看似可解析的部分:

/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/distutils/system_info.py:1858: UserWarning:
          Lapack (http://www.netlib.org/lapack/) sources not found.
          Directories to search for the sources can be specified in the
          numpy/distutils/site.cfg file (section [lapack_src]) or by setting
          the LAPACK_SRC environment variable.
        return getattr(self, '_calc_info_{}'.format(name))()
        NOT AVAILABLE
  
      Traceback (most recent call last):
        File "<string>", line 1, in <module>
        File "/private/var/folders/tc/fyyvwny94vxbjt8jkbh3dsw80000gn/T/pip-install-bq_6j9py/scipy_f3e554e9307743fd9a601d545335a0a7/setup.py", line 492, in <module>
          setup_package()
        File "/private/var/folders/tc/fyyvwny94vxbjt8jkbh3dsw80000gn/T/pip-install-bq_6j9py/scipy_f3e554e9307743fd9a601d545335a0a7/setup.py", line 488, in setup_package
          setup(**metadata)
        File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/distutils/core.py", line 135, in setup
          config = configuration()
        File "/private/var/folders/tc/fyyvwny94vxbjt8jkbh3dsw80000gn/T/pip-install-bq_6j9py/scipy_f3e554e9307743fd9a601d545335a0a7/setup.py", line 395, in configuration
          raise NotFoundError(msg)
      numpy.distutils.system_info.NotFoundError: No lapack/blas resources found. Note: Accelerate is no longer supported.

      ----------------------------------------
      ERROR: Command errored out with exit status 1: /Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/tc/fyyvwny94vxbjt8jkbh3dsw80000gn/T/pip-install-bq_6j9py/scipy_f3e554e9307743fd9a601d545335a0a7/setup.py'"'"'; __file__='"'"'/private/var/folders/tc/fyyvwny94vxbjt8jkbh3dsw80000gn/T/pip-install-bq_6j9py/scipy_f3e554e9307743fd9a601d545335a0a7/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/tc/fyyvwny94vxbjt8jkbh3dsw80000gn/T/pip-record-_r3hwab1/install-record.txt --single-version-externally-managed --prefix /private/var/folders/tc/fyyvwny94vxbjt8jkbh3dsw80000gn/T/pip-build-env-4qfk0eep/overlay --compile --install-headers /private/var/folders/tc/fyyvwny94vxbjt8jkbh3dsw80000gn/T/pip-build-env-4qfk0eep/overlay/include/python3.10/scipy Check the logs for full command output.
      ----------------------------------------
    WARNING: Discarding https://files.pythonhosted.org/packages/62/7c/596ff7b32f655f379d3abdfa82607e5cb3b70f46baad4604706511cfeb85/scikit-learn-1.0.1.tar.gz#sha256=ac2ca9dbb754d61cfe1c83ba8483498ef951d29b93ec09d6f002847f210a99da (from https://pypi.org/simple/scikit-learn/) (requires-python:>=3.7). Command errored out with exit status 1: /Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10 /private/var/folders/tc/fyyvwny94vxbjt8jkbh3dsw80000gn/T/pip-standalone-pip-ij4zyayw/__env_pip__.zip/pip install --ignore-installed --no-user --prefix /private/var/folders/tc/fyyvwny94vxbjt8jkbh3dsw80000gn/T/pip-build-env-4qfk0eep/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools wheel 'Cython>=0.28.5' 'oldest-supported-numpy; python_version!='"'"'3.7'"'"' or platform_machine=='"'"'aarch64'"'"' or platform_system=='"'"'AIX'"'"' or platform_python_implementation == '"'"'PyPy'"'"'' 'numpy==1.14.6; python_version=='"'"'3.7'"'"' and platform_machine!='"'"'aarch64'"'"' and platform_system!='"'"'AIX'"'"' and platform_python_implementation != '"'"'PyPy'"'"'' 'scipy>=1.1.0' Check the logs for full command output.
      Using cached scikit-learn-1.0.tar.gz (7.8 MB)
      Installing build dependencies ... /

As you can see at the bottom, it tries to continue with no success.正如您在底部看到的,它试图继续但没有成功。

Solved by using pip install sci-kitlearn instead of sklearn .通过使用pip install sci-kitlearn而不是sklearn Sorry, could have sworn it was sklearn !对不起,可以发誓这是sklearn

I am facing same problem on python 3.10+ and 3.9+ version我在python 3.10+ 和 3.9+版本上面临同样的问题

Then I switch python version 3.8+ and its working fine然后我切换 python 版本3.8+并且它工作正常

If your using conda then you can simply create a new environment如果您使用 conda 那么您可以简单地创建一个新环境

conda create -n yourenvname python=3.8

Then Activate your new environment然后激活你的新环境

conda actiavate yourenvname 

Then Install sklearn:然后安装sklearn:

pip install sci-kitlearn

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM