MacOS M1/M2/M3芯片如何安装Python3.6

时间:2025-04-07 07:44:56
#Install Rosetta /usr/sbin/softwareupdate --install-rosetta --agree-to-license # Install x86_64 brew arch -x86_64 /bin/bash -c "$(curl -fsSL /Homebrew/install/master/)" # Set up x86_64 homebrew and pyenv and temporarily set aliases alias brew86="arch -x86_64 /usr/local/bin/brew" alias pyenv86="arch -x86_64 pyenv" # Install required packages and flags for building this particular python version through emulation brew86 install pyenv gcc libffi gettext # 注意一定要安装正确的openssl版本,后续指定的PYTHON_BUILD_HOMEBREW_OPENSSL_FORMULA情况下,pyenv安装也会自动安装 brew86 install openssl@1.1 # -------------- change to openssl@1.1 here and others as well ----------+# ↓ export CPPFLAGS="-I$(brew86 --prefix libffi)/include -I$(brew86 --prefix openssl@1.1)/include -I$(brew86 --prefix readline)/lib" export CFLAGS="-I$(brew86 --prefix openssl@1.1)/include -I$(brew86 --prefix bzip2)/include -I$(brew86 --prefix readline)/include -I$(xcrun --show-sdk-path)/usr/include -Wno-implicit-function-declaration" export LDFLAGS="-L$(brew86 --prefix openssl@1.1)/lib -L$(brew86 --prefix readline)/lib -L$(brew86 --prefix zlib)/lib -L$(brew86 --prefix bzip2)/lib -L$(brew86 --prefix gettext)/lib -L$(brew86 --prefix libffi)/lib" # Providing an incorrect openssl version forces a proper openssl version to be downloaded and linked during the build export PYTHON_BUILD_HOMEBREW_OPENSSL_FORMULA=openssl@1.1 # Install Python 3.6.4 pyenv86 install 3.6.4