Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pyenv cannot install python on MacOS M1

Pyenv will not install any version of python on my system (MacOS M1).

Here's the output from the terminal session:

pyenv install 3.9.0
python-build: use [email protected] 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...
patching file Misc/NEWS.d/next/Build/2021-10-11-16-27-38.bpo-45405.iSfdW5.rst
patching file configure
patching file configure.ac
python-build: use readline from homebrew
python-build: use zlib from xcode sdk

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

Inspect or clean up the working tree at /var/folders/rl/lwsby5952zs1d56sjyj0tcn00000gn/T/python-build.20220602111813.90726
Results logged to /var/folders/rl/lwsby5952zs1d56sjyj0tcn00000gn/T/python-build.20220602111813.90726.log

Last 10 log lines:
checking size of _Bool... 1
checking size of off_t... 8
checking whether to enable large file support... no
checking size of time_t... 8
checking for pthread_t... yes
checking size of pthread_t... 8
checking size of pthread_key_t... 8
checking whether pthread_key_t is compatible with int... no
configure: error: Unexpected output of 'arch' on OSX
make: *** No targets specified and no makefile found.  Stop.

Terminal Session (Warp)

I tried using the arch prefix as well:

arch -x86_64 pyenv install 3.8.9
python-build: use [email protected] from homebrew
python-build: use readline from homebrew
Downloading Python-3.8.9.tar.xz...
-> https://www.python.org/ftp/python/3.8.9/Python-3.8.9.tar.xz
Installing Python-3.8.9...
patching file Misc/NEWS.d/next/Build/2021-10-11-16-27-38.bpo-45405.iSfdW5.rst
patching file configure
patching file configure.ac
python-build: use readline from homebrew
python-build: use zlib from xcode sdk

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

Inspect or clean up the working tree at /var/folders/rl/lwsby5952zs1d56sjyj0tcn00000gn/T/python-build.20220602111231.79341
Results logged to /var/folders/rl/lwsby5952zs1d56sjyj0tcn00000gn/T/python-build.20220602111231.79341.log

Last 10 log lines:
  "_libintl_textdomain", referenced from:
      _PyIntl_textdomain in libpython3.8.a(_localemodule.o)
      _PyIntl_textdomain in libpython3.8.a(_localemodule.o)
ld: symbol(s) not found for architecture x86_64
ld: symbol(s) not found for architecture x86_64
clang: clang: error: error: linker command failed with exit code 1 (use -v to see invocation)
linker command failed with exit code 1 (use -v to see invocation)
make: *** [Programs/_testembed] Error 1
make: *** Waiting for unfinished jobs....
make: *** [python.exe] Error 1

Snippet from .zshrc:

# Pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(pyenv init -)"' >> ~/.zshrc
# Pyenv-virtualenv
eval "$(pyenv virtualenv-init -)"

export PYENV_ROOT="$HOME/.pyenv"
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"

Pyenv version: pyenv 2.3.1

Update: Resolved. It was a compatibility issue. pyenv doesn't support M1 for older versions of python (3.6/3.7/etc). Installing 3.7.13 or 3.10.0 both work.

like image 743
Ryan Cocuzzo Avatar asked Mar 17 '26 12:03

Ryan Cocuzzo


1 Answers

I am using M2 Ventura 13.2

  1. arch -arm64 pyenv install 3.11.1
  2. pyenv virtualenv 3.11.1 artifact
  3. pyenv local artifact
  4. pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cpu
  5. Check in the shell
>>> import torch

>>> torch.backends.mps.is_available()

True
like image 175
joe Avatar answered Mar 20 '26 01:03

joe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!