0

I am having a strange error on my MacBook Air (M1, 2020) where python3.8 is being installed as a 64 bit binary from homebrew brew install python@3.8 and yet, is being run in 32 bit mode, thus causing errors when trying to download packages.

Here is what I have tried:

  1. Reinstalling and confirming that the executable is running in 32 bit
$ brew reinstall python@3.8 #installs to /opt/homebrew/opt/python@3.8/bin/python3
$ python3.8 -c 'import sys;print("%x" % sys.maxsize, sys.maxsize > 2**64)'
> 7fffffffffffffff False
  1. Looking at architecture of binary
$ file /opt/homebrew/opt/python@3.8/bin/python3
> /opt/homebrew/opt/python@3.8/bin/python3: Mach-O 64-bit executable arm64

From the above output, one can see that the executable is in fact 64-bit despite being run in 32 bit mode.

  1. Additional installation of Rosetta 2, a mac update supposedly to fix this problem
$ /usr/sbin/softwareupdate --install-rosetta --agree-to-license
  1. Attempt to force binary in 64 bit arch
$ arch -x86_64 /opt/homebrew/opt/python@3.8/bin/python3
> arch: posix_spawnp: /opt/homebrew/opt/python@3.8/bin/python3: Bad CPU type in executable

Here is relevant, but sadly unhelpful for my needs, stack overflow tickets:

How to force using 64 bit python on Mac-os-X
Installation issue with Tensorflow Package
How to determine if python is in 32 or 64 bit mode mac
Bad CPU type in executable Mac Rosetta 2 Instructions

Any ideas would be helpful, thanks!

Blakedallen
  • 664
  • 1
  • 8
  • 23
  • 2
    Wait, your output implies to me that the exectuable is running in 64bit... – juanpa.arrivillaga Oct 25 '21 at 19:27
  • Good catch! I think I entered in the wrong command... 2\*\*64 instead of 2\*\*32, I will look into this further because after this confirmation it seems like the issue is due to the specific package or another unrelated issue. I will close this, but thanks! – Blakedallen Oct 25 '21 at 23:06

1 Answers1

0

Turns out I had an error in my command:

python3.8 -c 'import sys;print("%x" % sys.maxsize, sys.maxsize > 2**64)'

should be:

python3.8 -c 'import sys;print("%x" % sys.maxsize, sys.maxsize > 2**32)'

Which returns true when you're running python in 64 bit mode.

This specific problem is likely something else, and as such I am closing this question.

Blakedallen
  • 664
  • 1
  • 8
  • 23