繁体   English   中英

Pip安装pandas结果报错(Python3.8、Pycharm、Apple Silicon)

[英]Pip install pandas results in error (Python3.8, Pycharm, Apple Silicon)

通过pip install pandas出现以下错误。 我真的不知道该怎么做或如何解决它。 我希望我为您提供了足够的信息。 非常感谢您的帮助!

设置:

  • macOS BigSur 11.1
  • Apple Silicon,MacBook Pro(13 英寸,M1,2020 年)
  • Apple Silicon 2020.3.2 的 PyCharm CE。 通过 JetBrains Toolbox 管理
  • 使用 Python 3.9(也尝试使用 python 3.8,但结果相同的错误)

安装包:

  • pip 20.3.3
  • 安装工具 51.3.3

错误消息:使用缓存的 pandas-1.2.1.tar.gz (5.5 MB) 收集 pandas 安装构建依赖项:已开始安装构建依赖项:已完成,状态为“错误”

  ERROR: Command errored out with exit status 1:
   command: /Users/user/PycharmProjects/test1/venv/bin/python /Users/user/PycharmProjects/test1/venv/lib/python3.9/site-packages/pip install --ignore-installed --no-user --prefix /private/var/folders/vc/_39tpjws3jbb_wprblz865200000gn/T/pip-build-env-pdrftgon/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools wheel 'Cython>=0.29.21,<3' 'numpy==1.16.5; python_version=='"'"'3.7'"'"' and platform_system!='"'"'AIX'"'"'' 'numpy==1.17.3; python_version=='"'"'3.8'"'"' and platform_system!='"'"'AIX'"'"'' 'numpy==1.16.5; python_version=='"'"'3.7'"'"' and platform_system=='"'"'AIX'"'"'' 'numpy==1.17.3; python_version=='"'"'3.8'"'"' and platform_system=='"'"'AIX'"'"'' 'numpy; python_version>='"'"'3.9'"'"''
       cwd: None
  Complete output (1081 lines):
  Ignoring numpy: markers 'python_version == "3.7" and platform_system != "AIX"' don't match your environment
  Ignoring numpy: markers 'python_version == "3.8" and platform_system != "AIX"' don't match your environment
  Ignoring numpy: markers 'python_version == "3.7" and platform_system == "AIX"' don't match your environment
  Ignoring numpy: markers 'python_version == "3.8" and platform_system == "AIX"' don't match your environment
  Collecting Cython<3,>=0.29.21
    Using cached Cython-0.29.21-py2.py3-none-any.whl (974 kB)
  Collecting numpy
    Using cached numpy-1.19.5.zip (7.3 MB)
    Installing build dependencies: started
    Installing build dependencies: finished with status 'done'
    Getting requirements to build wheel: started
    Getting requirements to build wheel: finished with status 'done'
      Preparing wheel metadata: started
      Preparing wheel metadata: finished with status 'done'
  Collecting wheel
    Using cached wheel-0.36.2-py2.py3-none-any.whl (35 kB)
  Collecting setuptools
    Using cached setuptools-51.3.3-py3-none-any.whl (786 kB)
  Building wheels for collected packages: numpy
    Building wheel for numpy (PEP 517): started
    Building wheel for numpy (PEP 517): finished with status 'error'
    ERROR: Command errored out with exit status 1:
     command: /Users/user/PycharmProjects/test1/venv/bin/python /Users/user/PycharmProjects/test1/venv/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py build_wheel /var/folders/vc/_39tpjws3jbb_wprblz865200000gn/T/tmpt7i8fum9
         cwd: /private/var/folders/vc/_39tpjws3jbb_wprblz865200000gn/T/pip-install-10nrvsom/numpy_27b9d8e3033f43b4964c635b439e0373
    Complete output (1052 lines):
    Running from numpy source directory.
    Cythonizing sources
    numpy/random/_bounded_integers.pxd.in has not changed
    numpy/random/_philox.pyx has not changed
    numpy/random/_bounded_integers.pyx.in has not changed
    numpy/random/_sfc64.pyx has not changed
    numpy/random/_mt19937.pyx has not changed
    numpy/random/bit_generator.pyx has not changed
    Processing numpy/random/_bounded_integers.pyx
    numpy/random/mtrand.pyx has not changed
    numpy/random/_generator.pyx has not changed
    numpy/random/_pcg64.pyx has not changed
    numpy/random/_common.pyx has not changed
    blas_opt_info:
    blas_mkl_info:
    customize UnixCCompiler
      libraries mkl_rt not found in ['/Users/user/PycharmProjects/test1/venv/lib', '/usr/lib']
      NOT AVAILABLE
  
    clang: error: the clang compiler does not support 'faltivec', please use -maltivec and include altivec.h explicitly
    clang: error: the clang compiler does not support 'faltivec', please use -maltivec and include altivec.h explicitly
    clang: error: the clang compiler does not support 'faltivec', please use -maltivec and include altivec.h explicitly
    clang: error: the clang compiler does not support 'faltivec', please use -maltivec and include altivec.h explicitly
    clang: error: the clang compiler does not support 'faltivec', please use -maltivec and include altivec.h explicitly
    clang: error: the clang compiler does not support 'faltivec', please use -maltivec and include altivec.h explicitly
    clang: clang: errorerror: : the clang compiler does not support 'faltivec', please use -maltivec and include altivec.h explicitlythe clang compiler does not support 'faltivec', please use -maltivec and include altivec.h explicitly
  
    clang: error: the clang compiler does not support 'faltivec', please use -maltivec and include altivec.h explicitly
    clang: error: the clang compiler does not support 'faltivec', please use -maltivec and include altivec.h explicitly
    clang: error: the clang compiler does not support 'faltivec', please use -maltivec and include altivec.h explicitly
    clang: error: the clang compiler does not support 'faltivec', please use -maltivec and include altivec.h explicitly
    clang: error: the clang compiler does not support 'faltivec', please use -maltivec and include altivec.h explicitly
    clang: error: the clang compiler does not support 'faltivec', please use -maltivec and include altivec.h explicitly
    clang: error: the clang compiler does not support 'faltivec', please use -maltivec and include altivec.h explicitly
    error: Command "gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch arm64 -arch x86_64 -g -DNPY_INTERNAL_BUILD=1 -DHAVE_NPY_CONFIG_H=1 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -DNO_ATLAS_INFO=3 -DHAVE_CBLAS -Ibuild/src.macosx-10.9-universal2-3.9/numpy/core/src/umath -Ibuild/src.macosx-10.9-universal2-3.9/numpy/core/src/npymath -Ibuild/src.macosx-10.9-universal2-3.9/numpy/core/src/common -Inumpy/core/include -Ibuild/src.macosx-10.9-universal2-3.9/numpy/core/include/numpy -Inumpy/core/src/common -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -I/Users/user/PycharmProjects/test1/venv/include -I/Library/Frameworks/Python.framework/Versions/3.9/include/python3.9 -Ibuild/src.macosx-10.9-universal2-3.9/numpy/core/src/common -Ibuild/src.macosx-10.9-universal2-3.9/numpy/core/src/npymath -c numpy/core/src/multiarray/buffer.c -o build/temp.macosx-10.9-universal2-3.9/numpy/core/src/multiarray/buffer.o -MMD -MF build/temp.macosx-10.9-universal2-3.9/numpy/core/src/multiarray/buffer.o.d -faltivec -I/System/Library/Frameworks/vecLib.framework/Headers -std=c99" failed with exit status 1
    ----------------------------------------
    ERROR: Failed building wheel for numpy
  Failed to build numpy
  ERROR: Could not build wheels for numpy which use PEP 517 and cannot be installed directly
  ----------------------------------------
ERROR: Command errored out with exit status 1: /Users/user/PycharmProjects/test1/venv/bin/python /Users/user/PycharmProjects/test1/venv/lib/python3.9/site-packages/pip install --ignore-installed --no-user --prefix /private/var/folders/vc/_39tpjws3jbb_wprblz865200000gn/T/pip-build-env-pdrftgon/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools wheel 'Cython>=0.29.21,<3' 'numpy==1.16.5; python_version=='"'"'3.7'"'"' and platform_system!='"'"'AIX'"'"'' 'numpy==1.17.3; python_version=='"'"'3.8'"'"' and platform_system!='"'"'AIX'"'"'' 'numpy==1.16.5; python_version=='"'"'3.7'"'"' and platform_system=='"'"'AIX'"'"'' 'numpy==1.17.3; python_version=='"'"'3.8'"'"' and platform_system=='"'"'AIX'"'"'' 'numpy; python_version>='"'"'3.9'"'"'' Check the logs for full command output.

提示:我不得不删除错误消息,因为它有 90.000 个字符长(StackOverflow 只接受 30.000 个字符)

在 GitHub 上找到与此问题相关的类似线程。 解决方法如下

$ brew install python@3.9
$ brew install openblas
$ OPENBLAS="$(brew --prefix openblas)" MACOSX_DEPLOYMENT_TARGET=11.1 python3 -m pip install cython --no-use-pep517
$ OPENBLAS="$(brew --prefix openblas)" MACOSX_DEPLOYMENT_TARGET=11.1 python3 -m pip install numpy --no-use-pep517
$ OPENBLAS="$(brew --prefix openblas)" MACOSX_DEPLOYMENT_TARGET=11.1 python3 -m pip install pandas --no-use-pep517
$ OPENBLAS="$(brew --prefix openblas)" MACOSX_DEPLOYMENT_TARGET=11.1 python3 -m pip install pybind11 --no-use-pep517
$ OPENBLAS="$(brew --prefix openblas)" MACOSX_DEPLOYMENT_TARGET=11.1 python3 -m pip install scipy --no-use-pep517
$ brew install libjpeg zlib
$ python3 -m pip install pillow
$ python3 -m pip install matplotlib

附上 GitHub的螺纹以供进一步参考

As explained in a comment in the GitHub's issue BUG: Error installing NumPy via Pip on macOS Big Sur with python from HomeBrew #17784 , the key is to replace Mac OS BLAS by openblas for pip install :

brew install openblas
OPENBLAS="$(brew --prefix openblas)" pip install numpy pandas

我有脚本错误。 Adithya Kamath 的解决方案几乎对我有用。 但我仍然有一些错误。 我检查了问题的根源,发现模块“pythran”丢失了。 pip3 安装 pythran

接着

OPENBLAS="$(brew --prefix openblas)" MACOSX_DEPLOYMENT_TARGET=11.1 python3 -m pip 安装 scipy --no-use-pep517

然后就可以了。

我尝试了一切,但没有一个答案有帮助。 最后,有效的是使用 pyenv 将 python 更新到最新版本(当前为3.11.1 )。

我做了以下

在 macOS 上使用 Homebrew 安装pyenv

brew update
brew install pyenv

更新环境变量

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(pyenv init -)"' >> ~/.zshrc
source ~/.zshrc

重新启动您的终端应用程序

exec "$SHELL"

安装最新版本python

pyenv install 3.11

安装后设置为你的全球版本

pyenv global 3.11

评估pyenv路径

eval "$(pyenv init --path)"

验证系统正在使用的当前python版本

python3 --version

现在安装依赖

pip install -r your_requirements.txt

我也通过在Rosetta中使用终端完成了这一步

我参考了这个 SO answer How to downgrade python version from 3.8 to 3.7 (mac)

暂无
暂无

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

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