首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Mac M1上安装python依赖项时出错

在Mac M1上安装python依赖项时出错
EN

Stack Overflow用户
提问于 2022-07-05 20:55:04
回答 2查看 1.1K关注 0票数 0

我正在尝试安装一个名为fastrank的依赖项,该依赖项目前正在两个不同的苹果英特尔芯片上安装。然而,当我尝试用M1芯片在两个不同的mac上运行它时,我会得到以下错误:

代码语言:javascript
复制
***Collecting fastrank
  Using cached fastrank-0.7.0.tar.gz (52 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [27 lines of output]
      ⚠️  Warning: Please use maturin in pyproject.toml with a version constraint, e.g. `requires = ["maturin>=0.12,<0.13"]`. This will become an error.
       maturin failed
        Caused by: Cargo metadata failed. Does your crate compile with `cargo build`?
        Caused by: `cargo metadata` exited with an error:     Updating crates.io index
      warning: spurious network error (2 tries remaining): http parser error: stream ended at an unexpected time; class=Http (34)
      warning: spurious network error (1 tries remaining): http parser error: stream ended at an unexpected time; class=Http (34)
      error: failed to get `bzip2` as a dependency of package `fastrank v0.7.0 (/private/var/folders/5l/sppq3g8556nffpc74l_54zv40000gn/T/pip-install-ugbpj9al/fastrank_b60c765ae0df4f76b49d90ab4a21f9f2)`
      
      Caused by:
        failed to load source for dependency `bzip2`
      
      Caused by:
        Unable to update registry `crates-io`
      
      Caused by:
        failed to fetch `https://github.com/rust-lang/crates.io-index`
      
      Caused by:
        network failure seems to have happened
        if a proxy or similar is necessary `net.git-fetch-with-cli` may help here
        https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli
      
      Caused by:
        http parser error: stream ended at an unexpected time; class=Http (34)
      Error running maturin: Command '['maturin', 'pep517', 'write-dist-info', '--metadata-directory', '/private/var/folders/5l/sppq3g8556nffpc74l_54zv40000gn/T/pip-modern-metadata-hdyh51_d', '--interpreter', '/Users/chinwekele/.pyenv/versions/3.7.13/bin/python3']' returned non-zero exit status 1.
      Checking for Rust toolchain....
      Running `maturin pep517 write-dist-info --metadata-directory /private/var/folders/5l/sppq3g8556nffpc74l_54zv40000gn/T/pip-modern-metadata-hdyh51_d --interpreter /Users/chinwekele/.pyenv/versions/3.7.13/bin/python3`
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

有人知道如何解决这个错误吗?我试过使用Rosseta终端,尝试下载和运行各种软件包,以为它们会有所帮助,但都没有奏效。会感谢你的回应。

EN

回答 2

Stack Overflow用户

发布于 2022-09-23 13:16:49

对于Mac来说,如果使用康达,就有可能解决这个问题。这样做的目的是在Mac上创建一个x86环境,然后再进行pip安装。

代码语言:javascript
复制
conda create -n <name>
conda activate <name>
conda config --env --set subdir osx-64
conda install python=3.8

这里我选择Python3.8,但您可以选择另一个版本。

票数 1
EN

Stack Overflow用户

发布于 2022-07-05 21:22:16

  1. 在罗塞塔终端中,安装x86的本地brew,如解释的这里
  2. 然后使用此命令安装python版本(例如3.7)
代码语言:javascript
复制
arch -x86_64 brew install python@3.7
  1. 然后使用正确的x86版本的pip (位于x86 python安装旁边)安装fastrank。
代码语言:javascript
复制
/usr/local/Cellar/python@3.7/3.7.13_1/bin/pip3 install fastrank

为了简化一切(所以您不必每次都提供完整的路径),您可以为英特尔、x86、pip和python创建一个别名,就像在.zhsrc中那样:

代码语言:javascript
复制
alias ipython='/usr/local/Cellar/python@3.7/3.7.13_1/bin/python3.7'
alias ipip='/usr/local/Cellar/python@3.7/3.7.13_1/bin/pip3'

当您想使用英特尔ipip版本时,请使用ipython和x86

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72875415

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档