繁体   English   中英

在 macOS BigSur 上使用自制软件 python 安装 numpy 的问题

[英]problems installing numpy with homebrew python on macOS BigSur

我有 macOS BigSur -> 安装了 CommandLineTools 12.3 beta -> 安装了 homebrew -> 安装了 python 3.8 和brew install python@3.8 Python 运行良好,并在我使用python3命令时出现。 但是,当我尝试使用pip3 install numpy安装 NumPy 时, pip3 install numpy以下错误。 我将衷心感谢您的帮助

Collecting numpy
  Using cached numpy-1.19.4.zip (7.3 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/local/opt/python@3.8/bin/python3.8 /usr/local/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /var/folders/pt/_zy2t2xj0mvbh41_pm942s8m0000gn/T/tmp7cqupall
         cwd: /private/var/folders/pt/_zy2t2xj0mvbh41_pm942s8m0000gn/T/pip-install-0ccafnfa/numpy
    Complete output (227 lines):
    Processing numpy/random/_bounded_integers.pxd.in
    Processing numpy/random/_philox.pyx
    Processing numpy/random/_bounded_integers.pyx.in
    Processing numpy/random/_sfc64.pyx
    Processing numpy/random/_mt19937.pyx
    Processing numpy/random/bit_generator.pyx
    Processing numpy/random/mtrand.pyx
    Processing numpy/random/_generator.pyx
    Processing numpy/random/_pcg64.pyx
    Processing numpy/random/_common.pyx
    Cythonizing sources
    blas_opt_info:
    blas_mkl_info:
    customize UnixCCompiler
      libraries mkl_rt not found in ['/usr/local/Cellar/python@3.8/3.8.6_1/Frameworks/Python.framework/Versions/3.8/lib', '/usr/local/lib', '/usr/lib']
      NOT AVAILABLE
    
    blis_info:
      libraries blis not found in ['/usr/local/Cellar/python@3.8/3.8.6_1/Frameworks/Python.framework/Versions/3.8/lib', '/usr/local/lib', '/usr/lib']
      NOT AVAILABLE
    
    openblas_info:
      libraries openblas not found in ['/usr/local/Cellar/python@3.8/3.8.6_1/Frameworks/Python.framework/Versions/3.8/lib', '/usr/local/lib', '/usr/lib']
      NOT AVAILABLE
    
    atlas_3_10_blas_threads_info:
    Setting PTATLAS=ATLAS
      libraries tatlas not found in ['/usr/local/Cellar/python@3.8/3.8.6_1/Frameworks/Python.framework/Versions/3.8/lib', '/usr/local/lib', '/usr/lib']
      NOT AVAILABLE
    
    atlas_3_10_blas_info:
      libraries satlas not found in ['/usr/local/Cellar/python@3.8/3.8.6_1/Frameworks/Python.framework/Versions/3.8/lib', '/usr/local/lib', '/usr/lib']
      NOT AVAILABLE
    
    atlas_blas_threads_info:
    Setting PTATLAS=ATLAS
      libraries ptf77blas,ptcblas,atlas not found in ['/usr/local/Cellar/python@3.8/3.8.6_1/Frameworks/Python.framework/Versions/3.8/lib', '/usr/local/lib', '/usr/lib']
      NOT AVAILABLE
    
    atlas_blas_info:
      libraries f77blas,cblas,atlas not found in ['/usr/local/Cellar/python@3.8/3.8.6_1/Frameworks/Python.framework/Versions/3.8/lib', '/usr/local/lib', '/usr/lib']
      NOT AVAILABLE
    
    accelerate_info:
      libraries accelerate not found in ['/usr/local/Cellar/python@3.8/3.8.6_1/Frameworks/Python.framework/Versions/3.8/lib', '/usr/local/lib', '/usr/lib']
    Library accelerate was not found. Ignoring
      libraries veclib not found in ['/usr/local/Cellar/python@3.8/3.8.6_1/Frameworks/Python.framework/Versions/3.8/lib', '/usr/local/lib', '/usr/lib']
    Library veclib was not found. Ignoring
      FOUND:
        extra_compile_args = ['-msse3', '-I/System/Library/Frameworks/vecLib.framework/Headers']
        extra_link_args = ['-Wl,-framework', '-Wl,Accelerate']
        define_macros = [('NO_ATLAS_INFO', 3), ('HAVE_CBLAS', None)]
    
      FOUND:
        extra_compile_args = ['-msse3', '-I/System/Library/Frameworks/vecLib.framework/Headers']
        extra_link_args = ['-Wl,-framework', '-Wl,Accelerate']
        define_macros = [('NO_ATLAS_INFO', 3), ('HAVE_CBLAS', None)]
    
    non-existing path in 'numpy/distutils': 'site.cfg'
    lapack_opt_info:
    lapack_mkl_info:
      libraries mkl_rt not found in ['/usr/local/Cellar/python@3.8/3.8.6_1/Frameworks/Python.framework/Versions/3.8/lib', '/usr/local/lib', '/usr/lib']
      NOT AVAILABLE
    
    openblas_lapack_info:
      libraries openblas not found in ['/usr/local/Cellar/python@3.8/3.8.6_1/Frameworks/Python.framework/Versions/3.8/lib', '/usr/local/lib', '/usr/lib']
      NOT AVAILABLE
    
    openblas_clapack_info:
      libraries openblas,lapack not found in ['/usr/local/Cellar/python@3.8/3.8.6_1/Frameworks/Python.framework/Versions/3.8/lib', '/usr/local/lib', '/usr/lib']
      NOT AVAILABLE
    
    flame_info:
      libraries flame not found in ['/usr/local/Cellar/python@3.8/3.8.6_1/Frameworks/Python.framework/Versions/3.8/lib', '/usr/local/lib', '/usr/lib']
      NOT AVAILABLE
    
    atlas_3_10_threads_info:
    Setting PTATLAS=ATLAS
      libraries lapack_atlas not found in /usr/local/Cellar/python@3.8/3.8.6_1/Frameworks/Python.framework/Versions/3.8/lib
      libraries tatlas,tatlas not found in /usr/local/Cellar/python@3.8/3.8.6_1/Frameworks/Python.framework/Versions/3.8/lib
      libraries lapack_atlas not found in /usr/local/lib
      libraries tatlas,tatlas not found in /usr/local/lib
      libraries lapack_atlas not found in /usr/lib
      libraries tatlas,tatlas not found in /usr/lib
    <class 'numpy.distutils.system_info.atlas_3_10_threads_info'>
      NOT AVAILABLE
    
    atlas_3_10_info:
      libraries lapack_atlas not found in /usr/local/Cellar/python@3.8/3.8.6_1/Frameworks/Python.framework/Versions/3.8/lib
      libraries satlas,satlas not found in /usr/local/Cellar/python@3.8/3.8.6_1/Frameworks/Python.framework/Versions/3.8/lib
      libraries lapack_atlas not found in /usr/local/lib
      libraries satlas,satlas not found in /usr/local/lib
      libraries lapack_atlas not found in /usr/lib
      libraries satlas,satlas not found in /usr/lib
    <class 'numpy.distutils.system_info.atlas_3_10_info'>
      NOT AVAILABLE
    
    atlas_threads_info:
    Setting PTATLAS=ATLAS
      libraries lapack_atlas not found in /usr/local/Cellar/python@3.8/3.8.6_1/Frameworks/Python.framework/Versions/3.8/lib
      libraries ptf77blas,ptcblas,atlas not found in /usr/local/Cellar/python@3.8/3.8.6_1/Frameworks/Python.framework/Versions/3.8/lib
      libraries lapack_atlas not found in /usr/local/lib
      libraries ptf77blas,ptcblas,atlas not found in /usr/local/lib
      libraries lapack_atlas not found in /usr/lib
      libraries ptf77blas,ptcblas,atlas not found in /usr/lib
    <class 'numpy.distutils.system_info.atlas_threads_info'>
      NOT AVAILABLE
    
    atlas_info:
      libraries lapack_atlas not found in /usr/local/Cellar/python@3.8/3.8.6_1/Frameworks/Python.framework/Versions/3.8/lib
      libraries f77blas,cblas,atlas not found in /usr/local/Cellar/python@3.8/3.8.6_1/Frameworks/Python.framework/Versions/3.8/lib
      libraries lapack_atlas not found in /usr/local/lib
      libraries f77blas,cblas,atlas not found in /usr/local/lib
      libraries lapack_atlas not found in /usr/lib
      libraries f77blas,cblas,atlas not found in /usr/lib
    <class 'numpy.distutils.system_info.atlas_info'>
      NOT AVAILABLE
    
      FOUND:
        extra_compile_args = ['-msse3', '-I/System/Library/Frameworks/vecLib.framework/Headers']
        extra_link_args = ['-Wl,-framework', '-Wl,Accelerate']
        define_macros = [('NO_ATLAS_INFO', 3), ('HAVE_CBLAS', None)]
    
    running dist_info
    running build_src
    build_src
    building py_modules sources
    creating build
    creating build/src.macosx-11.0-x86_64-3.8
    creating build/src.macosx-11.0-x86_64-3.8/numpy
    creating build/src.macosx-11.0-x86_64-3.8/numpy/distutils
    building library "npymath" sources
    Could not locate executable gfortran
    Could not locate executable f95
    Could not locate executable f90
    Could not locate executable f77
    Could not locate executable xlf90
    Could not locate executable xlf
    Could not locate executable ifort
    Could not locate executable ifc
    Could not locate executable g77
    Could not locate executable g95
    Could not locate executable pgfortran
    don't know how to compile Fortran code on platform 'posix'
    creating build/src.macosx-11.0-x86_64-3.8/numpy/core
    creating build/src.macosx-11.0-x86_64-3.8/numpy/core/src
    creating build/src.macosx-11.0-x86_64-3.8/numpy/core/src/npymath
    conv_template:> build/src.macosx-11.0-x86_64-3.8/numpy/core/src/npymath/npy_math_internal.h
      adding 'build/src.macosx-11.0-x86_64-3.8/numpy/core/src/npymath' to include_dirs.
    conv_template:> build/src.macosx-11.0-x86_64-3.8/numpy/core/src/npymath/ieee754.c
    conv_template:> build/src.macosx-11.0-x86_64-3.8/numpy/core/src/npymath/npy_math_complex.c
    None - nothing done with h_files = ['build/src.macosx-11.0-x86_64-3.8/numpy/core/src/npymath/npy_math_internal.h']
    building library "npysort" sources
    creating build/src.macosx-11.0-x86_64-3.8/numpy/core/src/common
    conv_template:> build/src.macosx-11.0-x86_64-3.8/numpy/core/src/common/npy_sort.h
      adding 'build/src.macosx-11.0-x86_64-3.8/numpy/core/src/common' to include_dirs.
    creating build/src.macosx-11.0-x86_64-3.8/numpy/core/src/npysort
    conv_template:> build/src.macosx-11.0-x86_64-3.8/numpy/core/src/npysort/quicksort.c
    conv_template:> build/src.macosx-11.0-x86_64-3.8/numpy/core/src/npysort/mergesort.c
    conv_template:> build/src.macosx-11.0-x86_64-3.8/numpy/core/src/npysort/timsort.c
    conv_template:> build/src.macosx-11.0-x86_64-3.8/numpy/core/src/npysort/heapsort.c
    conv_template:> build/src.macosx-11.0-x86_64-3.8/numpy/core/src/npysort/radixsort.c
    conv_template:> build/src.macosx-11.0-x86_64-3.8/numpy/core/src/common/npy_partition.h
    conv_template:> build/src.macosx-11.0-x86_64-3.8/numpy/core/src/npysort/selection.c
    conv_template:> build/src.macosx-11.0-x86_64-3.8/numpy/core/src/common/npy_binsearch.h
    conv_template:> build/src.macosx-11.0-x86_64-3.8/numpy/core/src/npysort/binsearch.c
    None - nothing done with h_files = ['build/src.macosx-11.0-x86_64-3.8/numpy/core/src/common/npy_sort.h', 'build/src.macosx-11.0-x86_64-3.8/numpy/core/src/common/npy_partition.h', 'build/src.macosx-11.0-x86_64-3.8/numpy/core/src/common/npy_binsearch.h']
    building library "npyrandom" sources
    building extension "numpy.core._multiarray_tests" sources
    creating build/src.macosx-11.0-x86_64-3.8/numpy/core/src/multiarray
    conv_template:> build/src.macosx-11.0-x86_64-3.8/numpy/core/src/multiarray/_multiarray_tests.c
    building extension "numpy.core._multiarray_umath" sources
    Running from numpy source directory.
    setup.py:480: UserWarning: Unrecognized setuptools command, proceeding with generating Cython sources and expanding templates
      run_build = parse_setuppy_commands()
    /usr/local/Cellar/python@3.8/3.8.6_1/Frameworks/Python.framework/Versions/3.8/lib/python3.8/distutils/dist.py:274: UserWarning: Unknown distribution option: 'define_macros'
      warnings.warn(msg)
    Traceback (most recent call last):
      File "/usr/local/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 280, in <module>
        main()
      File "/usr/local/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 263, in main
        json_out['return_val'] = hook(**hook_input['kwargs'])
      File "/usr/local/lib/python3.8/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/pt/_zy2t2xj0mvbh41_pm942s8m0000gn/T/pip-build-env-e1y5szqo/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 157, in prepare_metadata_for_build_wheel
        self.run_setup()
      File "/private/var/folders/pt/_zy2t2xj0mvbh41_pm942s8m0000gn/T/pip-build-env-e1y5szqo/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 248, in run_setup
        super(_BuildMetaLegacyBackend,
      File "/private/var/folders/pt/_zy2t2xj0mvbh41_pm942s8m0000gn/T/pip-build-env-e1y5szqo/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 142, in run_setup
        exec(compile(code, __file__, 'exec'), locals())
      File "setup.py", line 508, in <module>
        setup_package()
      File "setup.py", line 500, in setup_package
        setup(**metadata)
      File "/private/var/folders/pt/_zy2t2xj0mvbh41_pm942s8m0000gn/T/pip-install-0ccafnfa/numpy/numpy/distutils/core.py", line 169, in setup
        return old_setup(**new_attr)
      File "/private/var/folders/pt/_zy2t2xj0mvbh41_pm942s8m0000gn/T/pip-build-env-e1y5szqo/overlay/lib/python3.8/site-packages/setuptools/__init__.py", line 165, in setup
        return distutils.core.setup(**attrs)
      File "/usr/local/Cellar/python@3.8/3.8.6_1/Frameworks/Python.framework/Versions/3.8/lib/python3.8/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/usr/local/Cellar/python@3.8/3.8.6_1/Frameworks/Python.framework/Versions/3.8/lib/python3.8/distutils/dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "/usr/local/Cellar/python@3.8/3.8.6_1/Frameworks/Python.framework/Versions/3.8/lib/python3.8/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/private/var/folders/pt/_zy2t2xj0mvbh41_pm942s8m0000gn/T/pip-build-env-e1y5szqo/overlay/lib/python3.8/site-packages/setuptools/command/dist_info.py", line 31, in run
        egg_info.run()
      File "/private/var/folders/pt/_zy2t2xj0mvbh41_pm942s8m0000gn/T/pip-install-0ccafnfa/numpy/numpy/distutils/command/egg_info.py", line 24, in run
        self.run_command("build_src")
      File "/usr/local/Cellar/python@3.8/3.8.6_1/Frameworks/Python.framework/Versions/3.8/lib/python3.8/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/usr/local/Cellar/python@3.8/3.8.6_1/Frameworks/Python.framework/Versions/3.8/lib/python3.8/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/private/var/folders/pt/_zy2t2xj0mvbh41_pm942s8m0000gn/T/pip-install-0ccafnfa/numpy/numpy/distutils/command/build_src.py", line 144, in run
        self.build_sources()
      File "/private/var/folders/pt/_zy2t2xj0mvbh41_pm942s8m0000gn/T/pip-install-0ccafnfa/numpy/numpy/distutils/command/build_src.py", line 161, in build_sources
        self.build_extension_sources(ext)
      File "/private/var/folders/pt/_zy2t2xj0mvbh41_pm942s8m0000gn/T/pip-install-0ccafnfa/numpy/numpy/distutils/command/build_src.py", line 318, in build_extension_sources
        sources = self.generate_sources(sources, ext)
      File "/private/var/folders/pt/_zy2t2xj0mvbh41_pm942s8m0000gn/T/pip-install-0ccafnfa/numpy/numpy/distutils/command/build_src.py", line 378, in generate_sources
        source = func(extension, build_dir)
      File "numpy/core/setup.py", line 436, in generate_config_h
        moredefs, ignored = cocache.check_types(config_cmd, ext, build_dir)
      File "numpy/core/setup.py", line 47, in check_types
        out = check_types(*a, **kw)
      File "numpy/core/setup.py", line 292, in check_types
        raise SystemError(
    SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel.
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/local/opt/python@3.8/bin/python3.8 /usr/local/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /var/folders/pt/_zy2t2xj0mvbh41_pm942s8m0000gn/T/tmp7cqupall Check the logs for full command output.

通过使用 Rosetta 兼容层,我能够在全新的 Macbook Air(M1 芯片)上解决类似问题:

  1. 转到应用程序/实用程序并复制,然后将Terminal重命名为Terminal x86
  2. 右键单击Terminal x86 ,单击获取信息,然后选中Open using Rosetta

您现在应该可以毫无问题地使用 homebrew/pip/etc

几天前向numpy dev报告了一个问题,并打开了一个问题。 也许你想订阅这个线程;

BUG:使用 HomeBrew 中的 python 在 macOS Big Sur 上通过 Pip 安装 NumPy 时出错 #17784

它仍然有点混乱,但许多优秀的人正在研究解决方案; 这并不理想,但如果可以的话,也许你会等一会儿?

使用 Rosetta 打开终端并进行安装,这些问题都不会发生。

对于 Iterm,您可以在 Finder 中搜索iterm -> 右键单击​​ -> 获取信息 -> 选择“使用 Rosetta 打开”选项

对于 Pycharm 终端,您可以打开 Preferences -> Tools -> Terminal -> Update script path to "env /usr/bin/arch -x86_64 /bin/zsh --login"

如果您使用除此之外的终端,您可以通过谷歌搜索并找出使用 Rosetta 运行该终端的步骤。

转到Applications/Utilities复制它,然后将终端重命名为Terminal x86右键单击Terminal x86 ,单击获取信息,然后选中使用 Rosetta 打开

暂无
暂无

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

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