Try any of these:
❯ xcode-select --install
❯ xcode-select --reset
❯ export SDKROOT="macosx"
Maybe you don't have command line tools installed.
Or maybe you messed up the $DEVELOPER_DIR environment
variable path.
Or maybe your compiling with command line tools meant
for iPhone development or WatchOS !?!
❯ brew update && brew upgrade pyenv
Maybe your command versions aren't up to date ?
Double check you've properly followed the installation
steps for your version, OS and shell.
❯ brew install make cmake;
❯ export PATH="/usr/local/opt/make/libexec/gnubin:$PATH"
Maybe you don't have `make` and `cmake` build/compilation commands.
Or maybe they can't be found.
❯ brew install openssl readline tcl-tk sqlite3 xz zlib bzip2;
❯ export PATH="/usr/local/opt/bzip2/bin:$PATH";
export CPPFLAGS="\
-I$(xcrun --show-sdk-path)/usr/include \
-I$(brew --prefix openssl)/include \
-I$(brew --prefix readline)/include \
-I$(brew --prefix zlib)/include \
-I$(brew --prefix bzip2)/include";
export LDFLAGS="\
-L$(xcrun --show-sdk-path)/usr/lib \
-L$(brew --prefix openssl)/lib \
-L$(brew --prefix readline)/lib \
-L$(brew --prefix zlib)/lib \
-L$(brew --prefix bzip2)/lib";
Maybe you're missing some suggested `pyenv` build,
tools or what not. Or maybe they can't be found during
compilation.
https://github.com/pyenv/pyenv/wiki#suggested-build-environment
❯ unset LIBRARY
Maybe you've set/defined a LIBRARY environment variable
(either in your shell initialization/startup files,
e.g. .bashrc, .zshrc, etc; or shell session).
This can be bad because it could be used in the build/compilation
process and may crash it.
❯ pyenv install --verbose --patch 3.8.11 \
< <(curl -sSL https://github.com/python/cpython/commit/8ea6353.patch\?full_index\=1)
Maybe you haven't heard of the magical patch yet ?
which fixes issue with build process not taking into
account certain MacOS versions.
Also using the `--verbose` option, might give you
better hints as to what's going wrong.
❯ pyenv global 3.8.11 && eval "$(pyenv init -)"
OR
❯ pyenv global 3.8.11 && exec $SHELL --login
Also, don't forget to set your preferred global
python interpreter version and reinitialize `pyenv`
or restart your [login] shell altogether.
It may still not work, in that case just keep looking and post your answer when you've found it. Best Wishes.
Here are some of the resources I've consulted:
pyenv uninstall
in the same session. – Allheal