pythonpyenv

Trying to install python 3.9. using pyenv. Build failed on mac


I have a 3.12 python. But I need to downgrade or have multiple versions of python and I need 3.9 specifically. I tried installing using pyenv. Getting the following errors. Any help would be appreciated.

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

BUILD FAILED (OS X 13.6.7 using python-build 1.2.21)

Inspect or clean up the working tree at /tmp/python-build.20240806171953.65977
Results logged to /tmp/python-build.20240806171953.65977.log

Cat of the logs

(.venv) rmanoj@C02D76RZMD6R cicd % cat /tmp/python-build.20240806171953.65977.log 
/tmp/python-build.20240806171953.65977 ~/cicd
/tmp/python-build.20240806171953.65977/Python-3.9.0 /tmp/python-build.20240806171953.65977 ~/cicd
checking build system type... x86_64-apple-darwin22.6.0
checking host system type... x86_64-apple-darwin22.6.0
checking for python3.9... python3.9
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
checking MACHDEP... "darwin"
checking for gcc... clang
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether clang accepts -g... yes
checking for clang option to accept ISO C89... none needed
checking how to run the C preprocessor... clang -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for a sed that does not truncate output... /usr/local/bin/gsed
checking for --with-cxx-main=<compiler>... no
checking for clang++... no
configure:

Solution

  • you seem to have not installed xcode command line tools and dependencies for installing python builds. find the version of xcode command line tools for your macos from https://developer.apple.com/xcode/ and install. btw, you'll need to open an account with apple to download the xcode command line tools. Homebrew can help with installing dependencies and other dev tools, so consider installing that first from https://brew.sh/. then type this script on the terminal: 'brew install openssl readline sqlite3 xz zlib tcl-tk'. you can then install whatever python build you need with: 'pyenv install 3.9.0'.