Install python@2 on Mac with M1 chip
Asked Answered
S

4

49

Long story short, I want to install Apache Cassandra on a MacBook Pro with M1 chipset.

In order to install it, one must install other softwares before, one of them being python which must be updated to the latest version. I have followed this tutorial.

This is what terminal shows up when asking about python existing version:

> python --version 
Python 2.7.16

In tutorial they are updating it to 2.7.17, so I try to do the same:

> brew install python@2

and this is the output:

Warning: No available formula or cask with the name "python@2". Did you mean bpython, ipython, jython or cython?
==> Searching for similarly named formulae...
These similarly named formulae were found:
bpython             ipython             jython              cython
To install one of them, run (for example):
  brew install bpython
==> Searching for a previously deleted formula (in the last month)...
Error: No previously deleted formula found.
==> Searching taps on GitHub...
Error: No formulae found in taps.

Any ideas how to overcome this issue?

Stink answered 26/8, 2021 at 9:25 Comment(2)
what version of Cassandra are you installing? if 4, then it supports Python 3 out of boxBalladist
Looks like the built in MacBook Pro with M1 comes with Python 2.7.18 nowBaucis
B
119

I could install 2.7.18 on M1.

brew install pyenv
pyenv install 2.7.18

Set the python version.

pyenv global 2.7.18

Export PATH if necessary.

export PATH="$(pyenv root)/shims:${PATH}"

Add if necessary.:

echo 'PATH=$(pyenv root)/shims:$PATH' >> ~/.zshrc
Bui answered 25/3, 2022 at 17:8 Comment(5)
arch -arm64 brew install pyenvDylane
Before be able to invoke python invoke: $ pyenv global 2.7.18Joellajoelle
This might also be necessary: export PATH="$(pyenv root)/versions/2.7.18/bin:$PATH"Clangor
Tip: If it doen't work, its worth checking if you have an alias for python in your .zshrc file. Just remove any alias python=pytho3 and allow pyenv to take control.Basaltware
for me is a yes, you got talent my friend! xDNymph
M
6

Sometimes you will get some errors like missing something if you are using rosetta then run:

arch -arm64 pyenv install 2.7.18
Mornings answered 17/8, 2022 at 10:8 Comment(0)
H
3

For asdf version manager users, you can install the python plugin. Which wraps the pyenv.

asdf plugin add python

Then you can install python2 by calling

asdf install python 2.7.18

# Then you can declare the local python
asdf local python 2.7.18
Highpressure answered 13/9, 2023 at 13:57 Comment(0)
I
1

If you on the MacBook Pro with apple chip, arch -x86_64 is th key

arch -x86_64 pyenv install 2.7.18
Inflatable answered 26/1 at 7:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.