'Can't install pyenv 3.8.5 on MacOS Big Sur with M1 chip?
I am trying to run pyenv install 3.8.5 but keep getting the error below:
python-build: use [email protected] from homebrew
python-build: use readline from homebrew
Downloading Python-3.8.5.tar.xz...
-> https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tar.xz
Installing Python-3.8.5...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
BUILD FAILED (OS X 11.5.1 using python-build 20180424)
Inspect or clean up the working tree at /var/folders/61/8hkv2j8j6x7d7ldfq1d201b80000gp/T/python-build.20211009182855.32315
Results logged to /var/folders/61/8hkv2j8j6x7d7ldfq1d201b80000gp/T/python-build.20211009182855.32315.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.
Trying to install via homebrew. The weird thing is that I can install pyenv 3.9.6. I think it has something to do with that version not being compatible with the new silicon M1 chip. I've tried Problems installing python 3.6 with pyenv on Mac OS Big Sur and Issues Installing Python 3.x via Pyenv but nothing is working. Thanks in advance!!
Solution 1:[1]
https://www.python.org/downloads/release/python-391/
3.9.1 is the first version of Python to support macOS 11 Big Sur.
https://www.python.org/downloads/release/python-3810/
Python 3.8.10
... But there's a bunch of important updates here regardless, the biggest being Big Sur and Apple Silicon build support.
You cannot install 3.8.5, unfortunately.
Addendum:
Using pyenv and Rosetta, it might be possible to install older Python versions. From Python virtual environments with pyenv on Apple Silicon:
First of all, to be able to run x86 executables, we'll need to install Rosetta:
$ softwareupdate —install-rosetta
Now we can install the x86 Homebrew:
$ arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
It will be installed in the
/usr/local/bin/
directory. For convenience, you can create an alias by adding the following line in your shell configuration file:alias brew86="arch -x86_64 /usr/local/bin/brew"
Now we can invoke the x86 Homebrew as
brew86
and install packages required by pyenv:$ brew install openssl readline sqlite3 xz zlib $ brew86 install openssl readline sqlite3 xz zlib
You can check whether the installation was successful and you have packages for both architectures using the
file
command, for example:$ file /opt/homebrew/Cellar/[email protected]/1.1.1k/bin/openssl /opt/homebrew/Cellar/[email protected]/1.1.1k/bin/openssl: Mach-O 64-bit executable arm64 $ file /usr/local/Cellar/[email protected]/1.1.1k/bin/openssl /usr/local/Cellar/[email protected]/1.1.1k/bin/openssl: Mach-O 64-bit executable x86_64
To install x86 Python, you'll need to call pyenv with the
arch -x86_64 prefix
. For convenience, let's create an alias for this command by adding the following line in the shell config file:alias pyenv86="arch -x86_64 pyenv"
Now you can install x86 Python binaries by calling:
$ pyenv86 install <PYTHON_VERSION>
By default, pyenv doesn't allow you to specify custom names for the installed Python versions, but you can use the pyenv-alias plugin to give your installations appropriate names:
$ VERSION_ALIAS="3.x.x_x86" pyenv86 install 3.x.x
Note that with aliases for your pyenv and Homebrew installations, you’ll have to specify them in all commands and locations, for example:
$ CFLAGS="-I$(brew86 --prefix openssl)/include" \ LDFLAGS="-L$(brew86 --prefix openssl)/lib" \ VERSION_ALIAS="3.x.x_x86" \ pyenv86 install -v 3.x.x
Solution 2:[2]
I solved my issue of installing 3.7.6 using pyenv on macbook m1 using this solution. This also shows how to create a patch file that should help install other python versions. hope this helps.
Error installing python 3.7.6 using pyenv on new macbook pro M1 in OS 12.3+
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Tirtha Das |