Cannot Install Python 3.7 on Osx-Arm64

Error installing python 3.7.6 using pyenv on new macbook pro M1 in OS 12.3+

Finally this patch works in installing 3.7.6 on macbook m1 using pyenv.

To install python 3.7.6 version in mac os 12+ , M1 chip, apple clang version 13+ using pyenv, create a file anywhere in your local and call it python-3.7.6-m1.patch and copy the contents(below) to that file and save it.

diff --git a/configure b/configure
index b769d59629..8b018b6fe8 100755
--- a/configure
+++ b/configure
@@ -3370,7 +3370,7 @@ $as_echo "#define _BSD_SOURCE 1" >>confdefs.h
# has no effect, don't bother defining them
Darwin/[6789].*)
define_xopen_source=no;;
- Darwin/1[0-9].*)
+ Darwin/[12][0-9].*)
define_xopen_source=no;;
# On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
# used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined
@@ -5179,8 +5179,6 @@ $as_echo "$as_me:
fi


-MULTIARCH=$($CC --print-multiarch 2>/dev/null)
-

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for the platform triplet based on compiler characteristics" >&5
$as_echo_n "checking for the platform triplet based on compiler characteristics... " >&6; }
@@ -5338,6 +5336,11 @@ $as_echo "none" >&6; }
fi
rm -f conftest.c conftest.out

+if test x$PLATFORM_TRIPLET != xdarwin; then
+ MULTIARCH=$($CC --print-multiarch 2>/dev/null)
+fi
+
+
if test x$PLATFORM_TRIPLET != x && test x$MULTIARCH != x; then
if test x$PLATFORM_TRIPLET != x$MULTIARCH; then
as_fn_error $? "internal configure error for the platform triplet, please file a bug report" "$LINENO" 5
@@ -9247,6 +9250,9 @@ fi
ppc)
MACOSX_DEFAULT_ARCH="ppc64"
;;
+ arm64)
+ MACOSX_DEFAULT_ARCH="arm64"
+ ;;
*)
as_fn_error $? "Unexpected output of 'arch' on OSX" "$LINENO" 5
;;
diff --git a/configure.ac b/configure.ac
index 49acff3136..2f66184b26 100644
--- a/configure.ac
+++ b/configure.ac
@@ -490,7 +490,7 @@ case $ac_sys_system/$ac_sys_release in
# has no effect, don't bother defining them
Darwin/@<:@6789@:>@.*)
define_xopen_source=no;;
- Darwin/1@<:@0-9@:>@.*)
+ Darwin/@<:@[12]@:>@@<:@0-9@:>@.*)
define_xopen_source=no;;
# On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
# used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined
@@ -724,8 +724,7 @@ then
fi


-MULTIARCH=$($CC --print-multiarch 2>/dev/null)
-AC_SUBST(MULTIARCH)
+

AC_MSG_CHECKING([for the platform triplet based on compiler characteristics])
cat >> conftest.c <<EOF
@@ -880,6 +879,11 @@ else
fi
rm -f conftest.c conftest.out

+if test x$PLATFORM_TRIPLET != xdarwin; then
+ MULTIARCH=$($CC --print-multiarch 2>/dev/null)
+fi
+AC_SUBST(MULTIARCH)
+
if test x$PLATFORM_TRIPLET != x && test x$MULTIARCH != x; then
if test x$PLATFORM_TRIPLET != x$MULTIARCH; then
AC_MSG_ERROR([internal configure error for the platform triplet, please file a bug report])

Installation of earlier versions of Python (prior to 3.8) fails on Mac with M1 Chip (ARM based Apple Silicon)

Nix installed under Rosetta 2 will do the trick. I didn't even have it installed before running the below -- note the message showing Nix downloading Python 3.6 when I requested it.

# yes, this really is a M1 Mac
charles@macbook-pro ~ % uname -a
Darwin macbook-pro.lan 20.2.0 Darwin Kernel Version 20.2.0: Wed Dec 2 20:40:21 PST 2020; root:xnu-7195.60.75~1/RELEASE_ARM64_T8101 x86_64 i386 MacBookPro17,1 Darwin
charles@macbook-pro ~ % arch
arm64

# ...however, Rosetta was used to install an x86_64 Nix build
charles@macbook-pro ~ % file "$(realpath "$(command -v nix)")"
/nix/store/104sp9zrhmh3jycj32jcyl3f13mysdki-nix-2.3.9/bin/nix: Mach-O 64-bit executable x86_64

# ...and that x86_64 Nix build can install and run an x86_64 Python 3.6
charles@macbook-pro ~ % nix run nixpkgs.python36 -c python
[1 copied (53.7 MiB), 9.3 MiB DL]
Python 3.6.12 (default, Dec 18 2020, 15:32:50)
[GCC 4.2.1 Compatible Clang 7.1.0 (tags/RELEASE_710/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

The above (for reproducibility purposes) was collected with nixpkgs referring to the channel https://nixos.org/channels/nixpkgs-20.09-darwin, and specifically to the instance sn5ycj9wkbdmyinvqyg9rn42sw71wqad-nixpkgs-20.09pre245572.f18fbc33930.



Related Topics



Leave a reply



Submit