【问题标题】:Installing python tables on mac with m1 chip使用m1芯片在mac上安装python表
【发布时间】:2021-04-26 14:25:33
【问题描述】:

我正在尝试在带有 M1 芯片的新 mac mini 上使用 python3 中的表格。

运行HDF5_DIR=/opt/homebrew/Cellar/hdf5/1.12.0_1 pip3 install tables时遇到多个错误

    ERROR: Command errored out with exit status 1:
   command: /Library/Frameworks/Python.framework/Versions/3.9/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/wf/6qtzk3b11fxfpw2r195w68v40000gn/T/pip-install-vok5ylwx/tables_cf9b90e841c543338af0578c772dd962/setup.py'"'"'; __file__='"'"'/private/var/folders/wf/6qtzk3b11fxfpw2r195w68v40000gn/T/pip-install-vok5ylwx/tables_cf9b90e841c543338af0578c772dd962/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/wf/6qtzk3b11fxfpw2r195w68v40000gn/T/pip-wheel-_1y0kbny
       cwd: /private/var/folders/wf/6qtzk3b11fxfpw2r195w68v40000gn/T/pip-install-vok5ylwx/tables_cf9b90e841c543338af0578c772dd962/
  Complete output (293 lines):
  * Using Python 3.9.1 (v3.9.1:1e5d33e9b9, Dec  7 2020, 12:10:52)
  * USE_PKGCONFIG: False
  * Found HDF5 headers at ``/opt/homebrew/Cellar/hdf5/1.12.0_1/include``, library at ``/opt/homebrew/Cellar/hdf5/1.12.0_1/lib``.
  .. WARNING:: Could not find the HDF5 runtime.
     The HDF5 shared library was *not* found in the default library
     paths. In case of runtime problems, please remember to install it.
  /var/folders/wf/6qtzk3b11fxfpw2r195w68v40000gn/T/lzo_version_date5uv_p4uz.c:2:5: error: implicit declaration of function 'lzo_version_date' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
      lzo_version_date();
      ^
  1 error generated.
  * Could not find LZO 2 headers and library; disabling support for it.
  /var/folders/wf/6qtzk3b11fxfpw2r195w68v40000gn/T/lzo_version_datewh6xukqc.c:2:5: error: implicit declaration of function 'lzo_version_date' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
      lzo_version_date();
      ^
  1 error generated.
  * Could not find LZO 1 headers and library; disabling support for it.
  /var/folders/wf/6qtzk3b11fxfpw2r195w68v40000gn/T/BZ2_bzlibVersion0fv_km8c.c:2:5: error: implicit declaration of function 'BZ2_bzlibVersion' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
      BZ2_bzlibVersion();
      ^
  1 error generated.
  * Could not find bzip2 headers and library; disabling support for it.
  /var/folders/wf/6qtzk3b11fxfpw2r195w68v40000gn/T/blosc_list_compressorsqqaoy5ob.c:2:5: error: implicit declaration of function 'blosc_list_compressors' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
      blosc_list_compressors();
      ^
  1 error generated.
  * Could not find blosc headers and library; using internal sources.
  SSE2 detected and enabled
  /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py:274: UserWarning: Unknown distribution option: 'extra_require'
    warnings.warn(msg)

我安装了 blosc 并尝试通过 pip install python-lzo 安装 python-lzo 但得到

  ERROR: Command errored out with exit status 1:
   command: /Library/Frameworks/Python.framework/Versions/3.9/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/wf/6qtzk3b11fxfpw2r195w68v40000gn/T/pip-install-7vr_mnqv/python-lzo_a324aed1764741928cf19a18f366c948/setup.py'"'"'; __file__='"'"'/private/var/folders/wf/6qtzk3b11fxfpw2r195w68v40000gn/T/pip-install-7vr_mnqv/python-lzo_a324aed1764741928cf19a18f366c948/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/wf/6qtzk3b11fxfpw2r195w68v40000gn/T/pip-wheel-c1_ztyik
       cwd: /private/var/folders/wf/6qtzk3b11fxfpw2r195w68v40000gn/T/pip-install-7vr_mnqv/python-lzo_a324aed1764741928cf19a18f366c948/
  Complete output (12 lines):
  running bdist_wheel
  running build
  running build_ext
  building 'lzo' extension
  creating build
  creating build/temp.macosx-10.9-x86_64-3.9
  gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -I/usr/include/lzo -I/Library/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c lzomodule.c -o build/temp.macosx-10.9-x86_64-3.9/lzomodule.o
  lzomodule.c:35:10: fatal error: 'lzo/lzo1x.h' file not found
  #include <lzo/lzo1x.h>
           ^~~~~~~~~~~~~
  1 error generated.
  error: command '/usr/bin/gcc' failed with exit code 1
  ----------------------------------------
  ERROR: Failed building wheel for python-lzo

如果你能帮助我理解为什么表在 python2 上从来不是问题(诚然在 Windows 机器上,但我在 python3 上也遇到了所有类似的错误),那么奖励积分

【问题讨论】:

  • 你发现了吗?我面临着和你一样的问题。虽然我喜欢 m1 芯片,但它确实让软件开发成为一件苦差事。
  • 不,我没有。我最终擦除并重新安装了 Big Sur,这仅花费了几个小时,然后在 Apple 支持下又花了 3 个左右。我正在尝试通过 pyenv 进行全新安装,因为似乎 Python3 可以搞砸 mac 上的默认 python?

标签: python python-3.x pandas macos


【解决方案1】:

你可以试试这个链接 https://github.com/PyTables/PyTables/issues/219#issuecomment-24117053 经过多次搜索,我可以通过设置 HDF5_DIR 和

pip install git+https://github.com/PyTables/PyTables.git@master#egg=tables

【讨论】:

    【解决方案2】:

    这些步骤对我有用。

    1. 为 Mac M1 安装 Homebrew(arm64 版本)
    2. 然后安装包
    brew install hdf5 c-blosc lzo bzip2
    
    1. 检查安装路径
    brew info -q hdf5 c-blosc lzo bzip2|grep '/opt/homebrew'
    /opt/homebrew/Cellar/hdf5/1.12.0_3 (268 files, 19.4MB) *
    /opt/homebrew/Cellar/c-blosc/1.21.0 (10 files, 1.5MB) *
    /opt/homebrew/Cellar/lzo/2.10 (31 files, 580.4KB) *
    /opt/homebrew/Cellar/bzip2/1.0.8 (26 files, 531.5KB)
    ...
    
    1. 下载并取消归档 PyTables(我的 PyTables-3.6.1)
    2. 编译
    cd PyTables-3.6.1
    python setup.py build --hdf5=/opt/homebrew/Cellar/hdf5/1.12.0_3 --use-pkgconfig=FALSE --blosc=/opt/homebrew/Cellar/c-blosc/1.21.0 --lzo=/opt/homebrew/Cellar/lzo/2.10 --bzip2=/opt/homebrew/Cellar/bzip2/1.0.8
    
    1. 安装
    python setup.py install --hdf5=/opt/homebrew/Cellar/hdf5/1.12.0_3
    

    更新(2021-11-15):conda 现在可以工作了

    conda install pytables
    

    【讨论】:

      【解决方案3】:

      tables 模块可以使用 Miniforge 轻松安装(可以使用 pyenv 或按照其安装说明轻松安装):

      https://github.com/conda-forge/miniforge

      安装 Miniforge 后,您可以使用以下命令在 M1 Mac 上安装表格:

      conda install pytables
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2022-09-25
        • 2022-07-01
        • 1970-01-01
        • 2021-07-09
        • 1970-01-01
        • 2022-08-10
        • 2022-08-18
        相关资源
        最近更新 更多