Skip to content

Instantly share code, notes, and snippets.

@kaxing
Last active September 29, 2022 22:28
Show Gist options
  • Save kaxing/eaca6a6f36e6f98fbaad8be5763354aa to your computer and use it in GitHub Desktop.
Save kaxing/eaca6a6f36e6f98fbaad8be5763354aa to your computer and use it in GitHub Desktop.
Install latest python with asdf on macOS on Apple Silicon

References:

https://qiita.com/que9/items/28a9f7978fd34a620193
https://github.com/pyenv/pyenv/issues/1066#issuecomment-630939869
https://github.com/pyenv/pyenv/issues/2042#issuecomment-1131463276
https://stackoverflow.com/questions/51551557/pyenv-build-failed-installing-python-on-macos

The error:

ModuleNotFoundError: No module named '_socket'

The OS, shell and versions:

Processor: M1
OS: macOS 12.4
Shell: zsh 5.8.1 (x86_64-apple-darwin21.0)
asdf v0.10.2

The fix/workaround one-liner:

SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk \ MACOSX_DEPLOYMENT_TARGET=12.3 \ asdf install python latest

Still don't know why $SDKROOT is missing.

@asimihsan
Copy link

This similarly fixes installing Python 3.10.6 with pyenv

SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk MACOSX_DEPLOYMENT_TARGET=12.3 pyenv install 3.10.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment