繁体   English   中英

在 macOS 12.3 Monterey 上安装 Python 3.8.10 时出现问题

[英]Issues installing Python 3.8.10 on macOS 12.3 Monterey

有人在 macOS Monterey M1 Mac 上安装 python 3.8.10 时遇到问题吗? 我尝试使用pyenv install的任何版本都会给我这个错误:

python-build: use openssl@1.1 from homebrew python-build: use readline from homebrew Downloading Python-3.8.10.tar.xz... -> https://www.python.org/ftp/python/3.8.10/Python-3.8.10.tar.xz Installing Python-3.8.10... python-build: use readline from homebrew python-build: use zlib from xcode sdk

BUILD FAILED (OS X 12.3 using python-build 20180424)

Inspect or clean up the working tree at /var/folders/yg/s2w3pfj172v6kdwx7hvmq65m0000gn/T/python-build.20220322155830.88129 Results logged to /var/folders/yg/s2w3pfj172v6kdwx7hvmq65m0000gn/T/python-build.20220322155830.88129.log

Last 10 log lines: checking for --with-cxx-main=<compiler>... no checking for clang++... no configure:

By default, distutils will build C++ extension modules with "clang++". If this is not intended, then set CXX on the configure command line.

checking for the platform triplet based on compiler characteristics... darwin configure: error: internal configure error for the platform triplet, please file a bug report make: *** No targets specified and no makefile found.  Stop.

我在 Google 搜索中尝试了几乎所有问题,但都没有成功 =(。我尝试使用asdf python plugin and pyenv.

这对我有用。

先安装gcc;

brew install gcc

然后用 gcc 运行 pyenv 安装。

CC=/opt/homebrew/bin/gcc-11 pyenv install 3.8.10

在此处输入图像描述

Apple 引入了一项导致其崩溃的更改。

在您的特定情况下pyenv install 3.8.13应该可以工作。

对于不同版本的其他人应该检查这个线程

或使用任何这些版本 3.7.13、3.8.13、3.9.11 和 3.10.3

brew install gcc && CC=`which gcc-11` pyenv install 3.8.10

它不需要用brew安装gcc 它可能会让你陷入更多麻烦!

Apple Command Line Tools中有一个捆绑的gcc ,您可以通过以下命令找到它:

which gcc

注意不要在gcc中添加任何版本特定编号! gcc-11gcc-12等等。然后检查找到的gcc位于/Library/Developer/CommandLineTools/目录下。 所需的 output 将是这样的:

$ which gcc
/Library/Developer/CommandLineTools/usr/bin/gcc

如果一切正常,意味着您运行简单which gcc命令并找到gcc并且找到的路径位于/Library/Developer/CommandLineTools/目录下,您可以使用以下命令安装pyenv

CC=`which gcc` pyenv install 3.8.6

您可以安装任何可用且您需要的 python 版本。

如果您遇到任何问题,请发表评论,这可能有助于我们使答案更加清晰和对您有所帮助。

我遇到了同样的问题。 我意识到我的 pyenv 版本已经过时了。 我通过运行使用自制软件更新了它:

brew install pyenv

然后运行

pyenv install 3.10.6

完美地工作。

我帮助:

brew install gcc@11

后:

CC=`which gcc-11` pyenv install 3.8.12

我遇到了同样的问题,对我有用的解决方案是手动安装版本,以下是我为完成它而执行的步骤:

  1. 在此处下载 python-3.8.10 版本: https://www.python.org/downloads/release/python-3810/
  2. 下载后,双击通过安装向导进行安装。
  3. 完成后,从 finder 或终端打开安装目录: /Applications/Python 3.8
  4. 运行Install Certificates.command ,等待它完成。
  5. 在同一路径中,运行Update Shell Profile.command
  6. 你已经准备好了,验证它从终端运行: python3 --version

要为手动安装的 python 版本 3.8.10 设置虚拟环境:

  1. pip install --upgrade pip
  2. pip install virtualenv
  3. cd my_project_folder/
  4. virtualenv venv
  5. source venv/bin/activate
  6. 要在完成工作后停用,请运行: deactivate

您可以在此处获取有关设置虚拟环境的更多信息: https://virtualenv.pypa.io/en/latest/user_guide.html#

暂无
暂无

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

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