Pyenv cannot install python on MacOS M1
Asked Answered
R

3

11

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.

Rufous answered 2/6, 2022 at 16:38 Comment(5)
This might be of help: github.com/pyenv/pyenv/issues/1876#issuecomment-820996039.Elijah
That was it! It looks like the issue is deeper than just 3.9.0, the same issue occurs with the younger versions of 3.6, 3.7 and so on.Rufous
Please answer below rather than editing the question to say "resolved"Superinduce
@AniMenon Your edit fixed typos and wording, not syntax; misspelling "grammar" in the edit summary is a common typo, but particularly ironic here. (Other than that, thanks for a useful edit.)Tindle
@Tindle well actually it wasn't Grammar so Grammer :DGeary
C
2

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
Chargeable answered 6/2, 2023 at 7:20 Comment(2)
Sorry for reviving an old thread. Did you download pyenv and pyenv-virtualenv from brew or did you use the curl command?Penland
From curl command.Chargeable
A
0

Had the same issue trying to install python 3.11.5 with pyenv on mac with an ARM processor. Found a solution on some random Japanese forum :)

  1. Make sure you have Rosetta installed (Run pgrep oahd in your Terminal, if you see a process number in the output, you are OK)
  2. Open Finder, go to Applications, and find Terminal (it could be in the Utilities folder)
  3. Right-click on Terminal > Get info.
  4. Tick Open using Rosetta. Close the window and restart the Terminal.
  5. Run uname -m. You should see x86_64 in the output. (If you see arm64 your Terminal is not running with Rosetta)
  6. Run pyenv install 3.11.5 or another version.
Anastrophe answered 4/9, 2023 at 7:38 Comment(0)
M
-1

When dealing with Python>=3.9, if you need to install 100+ packages in the requirements.txt file, then avoid 3.9.0 and just install 3.9.4 or greater

% pyenv install 3.9.4

% pyenv virtualenv 3.9.4 my_example_env

Meretricious answered 26/7 at 16:49 Comment(1)
What exactly does "100+ packages in the requirements.txt" change about which answers are/aren't appropriate?Progestin

© 2022 - 2024 — McMap. All rights reserved.