Pyenv:无法安装 python 3.x 版 MacOS 12.3.1

Pyenv: Not able to install python 3.x version MacOS 12.3.1

我无法安装 python3.9.X(3.9.8、3.9.9、3.9.10、3.9.11)和 [=32] 的不同版本=] 他们正在工作。 我也尝试了一些 3.8.X 和 3.5.X 都给出了不同的错误。 我会 post 3.9.8 日志(我感兴趣的那个)

 Platform information: MacOS Monterey 12.3.1
 pyenv version: 2.2.5
 Python version: 3.9.8
 C Compiler information: Apple clang version 12.0.5 (clang-1205.0.22.9)
 Command used in pyenv: pyenv install 3.9.8 

这是我的 .zprofile(我正在使用 oh-my-zsh)

export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init --path)"

我也安装了所有required dependencies

brew install openssl readline sqlite3 xz zlib

在这里你可以找到 log and here you can find the config log

这就是我得到的:

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

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

Inspect or clean up the working tree at /var/folders/jl/hp_s9knj13x5ft7mffr258r40000gp/T/python-build.20220412182145.25030
Results logged to /var/folders/jl/hp_s9knj13x5ft7mffr258r40000gp/T/python-build.20220412182145.25030.log

Last 10 log lines:
if test $? -ne 0 ; then \
    echo "generate-posix-vars failed" ; \
    rm -f ./pybuilddir.txt ; \
    exit 1 ; \
fi
make: *** [Makefile:688: python.exe-gdb.py] Killed: 9
make: *** Waiting for unfinished jobs....
/bin/sh: line 5: 33970 Killed: 9               ./python.exe -E -S -m sysconfig --generate-posix-vars
generate-posix-vars failed
make: *** [Makefile:618: pybuilddir.txt] Error 1  

我花了几天时间解决这个问题,并在 GitHub 问题上找到了答案。
问题出在杀毒软件here

禁用防病毒软件后,一切都已安装且没有任何错误(我尝试了 python 3.9.8、3.9.9、3.9.10、3.9.11)。我有 Apex One (Mac) 防病毒软件,卸载并不简单。 This 指南很有帮助。

我使用了这两个命令:

sudo launchctl unload /Library/LaunchDaemons/com.trendmicro.* /Library/LaunchAgents/com.trendmicro.*
sudo kill -9 $(pgrep iCoreService TmLoginMgr)

如果您收到此警告完全没问题

Warning: Expecting a LaunchDaemons path since the command was ran as root. Got LaunchAgents instead.
`launchctl bootout` is a recommended alternative.
/Library/LaunchAgents/com.trendmicro.TmLoginMgr.plist: Could not find specified service
Unload failed: 113: Could not find specified service

只需检查顶部栏上的图标是否消失。
此外,您可以确保此命令不会 return 任何进程:

pgrep iCoreService TmLoginMgr MainUI