安装 scipy 时找不到库 mkl_rt、openblas、lapack - 如何更改库的标志

Posted

技术标签:

【中文标题】安装 scipy 时找不到库 mkl_rt、openblas、lapack - 如何更改库的标志【英文标题】:libraries mkl_rt, openblas, lapack not found while installing scipy - How to change flags for libraries 【发布时间】:2021-03-28 14:49:42 【问题描述】:

我是 python 和 pip 生态系统的新手。我正在尝试安装 scikit-image 并且我想它正在安装 scipy 作为依赖项。我正在使用 macOS 11.1,并且我知道对该版本的支持不是很好,因为它刚刚发布,但我能够通过更改几个标志(LDFLAGS、CPPFLAGS)来安装 numpy、pillow 等软件包。

谁能告诉我是否可以通过更改一些配置来解决以下安装错误?

我已经安装了 openblas、mkl_rt 库。

(trial) ~/.virtualenvs/trial python -m pip install scikit-image                                       
Collecting scikit-image
  Using cached scikit-image-0.17.2.tar.gz (29.8 MB)
Requirement already satisfied: numpy>=1.15.1 in ./lib/python3.6/site-packages (from scikit-image) (1.19.4)
Collecting scipy>=1.0.1
  Using cached scipy-1.5.4.tar.gz (25.2 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... error
    ERROR: Command errored out with exit status 1:
     command: /Users/myusername/.virtualenvs/trial/bin/python /Users/myusername/.virtualenvs/trial/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /var/folders/ss/d2f4tvvn7fzc42ls4hbrw06h0000gn/T/tmpk55uptaz
         cwd: /private/var/folders/ss/d2f4tvvn7fzc42ls4hbrw06h0000gn/T/pip-install-1v5ec7uf/scipy
    Complete output (137 lines):
    lapack_opt_info:
    lapack_mkl_info:
    customize UnixCCompiler
      libraries mkl_rt not found in ['/Users/myusername/.virtualenvs/trial/lib', '/usr/local/lib', '/usr/lib']
      NOT AVAILABLE
    
    openblas_lapack_info:
    customize UnixCCompiler
    customize UnixCCompiler
      libraries openblas not found in ['/Users/myusername/.virtualenvs/trial/lib', '/usr/local/lib', '/usr/lib']
      NOT AVAILABLE
    
    openblas_clapack_info:
    customize UnixCCompiler
    customize UnixCCompiler
      libraries openblas,lapack not found in ['/Users/myusername/.virtualenvs/trial/lib', '/usr/local/lib', '/usr/lib']
      NOT AVAILABLE
    
    atlas_3_10_threads_info:
    Setting PTATLAS=ATLAS
    customize UnixCCompiler
      libraries tatlas,tatlas not found in /Users/myusername/.virtualenvs/trial/lib
    customize UnixCCompiler
      libraries lapack_atlas not found in /Users/myusername/.virtualenvs/trial/lib
    customize UnixCCompiler
      libraries tatlas,tatlas not found in /usr/local/lib
    customize UnixCCompiler
      libraries lapack_atlas not found in /usr/local/lib
    customize UnixCCompiler
      libraries tatlas,tatlas not found in /usr/lib
    customize UnixCCompiler
      libraries lapack_atlas not found in /usr/lib
    <class 'numpy.distutils.system_info.atlas_3_10_threads_info'>
      NOT AVAILABLE
    
    atlas_3_10_info:
    customize UnixCCompiler
      libraries satlas,satlas not found in /Users/myusername/.virtualenvs/trial/lib
    customize UnixCCompiler
      libraries lapack_atlas not found in /Users/myusername/.virtualenvs/trial/lib
    customize UnixCCompiler
      libraries satlas,satlas not found in /usr/local/lib
    customize UnixCCompiler
      libraries lapack_atlas not found in /usr/local/lib
    customize UnixCCompiler
      libraries satlas,satlas not found in /usr/lib
    customize UnixCCompiler
      libraries lapack_atlas not found in /usr/lib
    <class 'numpy.distutils.system_info.atlas_3_10_info'>
      NOT AVAILABLE
    
    atlas_threads_info:
    Setting PTATLAS=ATLAS
    customize UnixCCompiler
      libraries ptf77blas,ptcblas,atlas not found in /Users/myusername/.virtualenvs/trial/lib
    customize UnixCCompiler
      libraries lapack_atlas not found in /Users/myusername/.virtualenvs/trial/lib
    customize UnixCCompiler
      libraries ptf77blas,ptcblas,atlas not found in /usr/local/lib
    customize UnixCCompiler
      libraries lapack_atlas not found in /usr/local/lib
    customize UnixCCompiler
      libraries ptf77blas,ptcblas,atlas not found in /usr/lib
    customize UnixCCompiler
      libraries lapack_atlas not found in /usr/lib
    <class 'numpy.distutils.system_info.atlas_threads_info'>
      NOT AVAILABLE
    
    atlas_info:
    customize UnixCCompiler
      libraries f77blas,cblas,atlas not found in /Users/myusername/.virtualenvs/trial/lib
    customize UnixCCompiler
      libraries lapack_atlas not found in /Users/myusername/.virtualenvs/trial/lib
    customize UnixCCompiler
      libraries f77blas,cblas,atlas not found in /usr/local/lib
    customize UnixCCompiler
      libraries lapack_atlas not found in /usr/local/lib
    customize UnixCCompiler
      libraries f77blas,cblas,atlas not found in /usr/lib
    customize UnixCCompiler
      libraries lapack_atlas not found in /usr/lib
    <class 'numpy.distutils.system_info.atlas_info'>
      NOT AVAILABLE
    
    lapack_info:
    customize UnixCCompiler
      libraries lapack not found in ['/Users/myusername/.virtualenvs/trial/lib', '/usr/local/lib', '/usr/lib']
      NOT AVAILABLE
    
    lapack_src_info:
      NOT AVAILABLE
    
      NOT AVAILABLE
    
    setup.py:462: UserWarning: Unrecognized setuptools command ('dist_info --egg-base /private/var/folders/ss/d2f4tvvn7fzc42ls4hbrw06h0000gn/T/pip-modern-metadata-tssa7s05'), proceeding with generating Cython sources and expanding templates
      ' '.join(sys.argv[1:])))
    Running from SciPy source directory.
    /private/var/folders/ss/d2f4tvvn7fzc42ls4hbrw06h0000gn/T/pip-build-env-_26ufpkr/overlay/lib/python3.6/site-packages/numpy/distutils/system_info.py:624: UserWarning:
        Atlas (http://math-atlas.sourceforge.net/) libraries not found.
        Directories to search for the libraries can be specified in the
        numpy/distutils/site.cfg file (section [atlas]) or by setting
        the ATLAS environment variable.
      self.calc_info()
    /private/var/folders/ss/d2f4tvvn7fzc42ls4hbrw06h0000gn/T/pip-build-env-_26ufpkr/overlay/lib/python3.6/site-packages/numpy/distutils/system_info.py:624: UserWarning:
        Lapack (http://www.netlib.org/lapack/) libraries not found.
        Directories to search for the libraries can be specified in the
        numpy/distutils/site.cfg file (section [lapack]) or by setting
        the LAPACK environment variable.
      self.calc_info()
    /private/var/folders/ss/d2f4tvvn7fzc42ls4hbrw06h0000gn/T/pip-build-env-_26ufpkr/overlay/lib/python3.6/site-packages/numpy/distutils/system_info.py:624: 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.
      self.calc_info()
    Traceback (most recent call last):
      File "/Users/myusername/.virtualenvs/trial/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 280, in <module>
        main()
      File "/Users/myusername/.virtualenvs/trial/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 263, in main
        json_out['return_val'] = hook(**hook_input['kwargs'])
      File "/Users/myusername/.virtualenvs/trial/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 133, in prepare_metadata_for_build_wheel
        return hook(metadata_directory, config_settings)
      File "/private/var/folders/ss/d2f4tvvn7fzc42ls4hbrw06h0000gn/T/pip-build-env-_26ufpkr/overlay/lib/python3.6/site-packages/setuptools/build_meta.py", line 161, in prepare_metadata_for_build_wheel
        self.run_setup()
      File "/private/var/folders/ss/d2f4tvvn7fzc42ls4hbrw06h0000gn/T/pip-build-env-_26ufpkr/overlay/lib/python3.6/site-packages/setuptools/build_meta.py", line 254, in run_setup
        self).run_setup(setup_script=setup_script)
      File "/private/var/folders/ss/d2f4tvvn7fzc42ls4hbrw06h0000gn/T/pip-build-env-_26ufpkr/overlay/lib/python3.6/site-packages/setuptools/build_meta.py", line 145, in run_setup
        exec(compile(code, __file__, 'exec'), locals())
      File "setup.py", line 583, in <module>
        setup_package()
      File "setup.py", line 579, in setup_package
        setup(**metadata)
      File "/private/var/folders/ss/d2f4tvvn7fzc42ls4hbrw06h0000gn/T/pip-build-env-_26ufpkr/overlay/lib/python3.6/site-packages/numpy/distutils/core.py", line 135, in setup
        config = configuration()
      File "setup.py", line 477, 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: /Users/myusername/.virtualenvs/trial/bin/python /Users/myusername/.virtualenvs/trial/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /var/folders/ss/d2f4tvvn7fzc42ls4hbrw06h0000gn/T/tmpk55uptaz Check the logs for full command output.

【问题讨论】:

你有充分的理由使用 Python 3.6 吗?大多数 SciPy 生态系统在 Big Sur 出现之前就停止支持 3.6,所以如果你使用更新的 Python,你会发现更好的支持。事实上,我只听说有人使用 Big Sur 获得 3.9。 @Juan 我试图将 numpy 与 python 3.8 一起用于我的其他项目,但由于 python 版本和大 sur 的一些问题,我无法安装它。所以我从一开始就为这个项目使用了 3.6。 你试过3.9吗? @Juan no 我放弃并安装了anaconda 我在 MacOS 11.2 上使用 Python 3.8 时遇到了同样的错误。但正如@Juan 所建议的,我将我的 Python 更新到 3.9,这个问题已经解决。 【参考方案1】:

我在使用通过 pyenv 安装的 Python 时遇到了同样的问题。 它缺少一些依赖项或路径未成功添加。

因此,要么您需要下载所有依赖项并将它们添加到您的 .profile 文件(bash 或 zsh)中,这些文件使用以下命令安装:

pyenv install (version)

或者,您可以尝试通过 HomeBrew 安装,它会下载所有依赖项/库并将它们添加到使用以下命令成功运行 python 程序所需的默认路径:

brew install python

这是一个不错的链接,您可以按照该链接获取详细说明:https://docs.python-guide.org/starting/install3/osx/

然后我注意到您正在使用虚拟环境。我建议在全新安装完成后创建一个新的虚拟环境。 (我知道这很明显);)

希望这能解决您缺少库的问题。

【讨论】:

嗨,Prashant,您提供的命令和链接用于安装 python 3。你为什么要安装“缺少的依赖项”呢?

以上是关于安装 scipy 时找不到库 mkl_rt、openblas、lapack - 如何更改库的标志的主要内容,如果未能解决你的问题,请参考以下文章

为啥我使用 setup.py 安装时找不到 ansible?

安装 CuSpatial 或 CuDf 库时找不到包错误

在沙箱中安装了 parsec,但在 ghci 中尝试加载文件时找不到库

编译时找不到动态库

使用 Cocoapods 时找不到 FMDB 库

在编译时找不到Spring数据存储库