Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

macos big sur - brew install python@2 doesnt work after uninstall python@2

after I tried to uninstall python 2.7

% brew uninstall python@2     

I cannot reinstall back python 2.7 on my mac (big sur)

% brew install python@2                                    
Error: 
  homebrew-core is a shallow clone.
  homebrew-cask is a shallow clone.
To `brew update`, first run:
  git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
  git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask fetch --unshallow
This restriction has been made on GitHub's request because updating shallow
clones is an extremely expensive operation due to the tree layout and traffic of
Homebrew/homebrew-core and Homebrew/homebrew-cask. We don't do this for you
automatically to avoid repeatedly performing an expensive unshallow operation in
CI systems (which should instead be fixed to not use shallow clones). Sorry for
the inconvenience!
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
Error: No available formula or cask with the name "python@2".
==> Searching for a previously deleted formula (in the last month)...
Warning: homebrew/core is shallow clone. To get complete history run:
  git -C "$(brew --repo homebrew/core)" fetch --unshallow

Error: No previously deleted formula found.
==> Searching taps on GitHub...
Error: No formulae found in taps.

UPDATE: I notice this as well

% pwd
/Library/Frameworks/Python.framework/Versions
% ls -al
total 0
drwxrwxr-x   6 root  wheel  192 Jan 11 14:18 .
drwxr-xr-x   6 root  wheel  192 Jan 11 14:18 ..
drwxrwxr-x  10 root  admin  320 Nov  8  2017 3.6
drwxrwxr-x  10 root  admin  320 Jan  2 18:24 3.8
drwxrwxr-x  11 root  admin  352 Jan 11 14:18 3.9
lrwxr-xr-x   1 root  wheel    3 Jan 11 14:18 Current -> 3.9
% python -V  
Python 2.7.16
% python3 -V
Python 3.9.1

in another location

% ls -al
total 0
drwxr-xr-x   7 root  wheel  224 Jan  1  2020 .
drwxr-xr-x   5 root  wheel  160 Jan  1  2020 ..
lrwxr-xr-x   1 root  wheel    3 Jan  1  2020 2.3 -> 2.7
lrwxr-xr-x   1 root  wheel    3 Jan  1  2020 2.5 -> 2.7
lrwxr-xr-x   1 root  wheel    3 Jan  1  2020 2.6 -> 2.7
drwxr-xr-x  11 root  wheel  352 Jan  1  2020 2.7
lrwxr-xr-x   1 root  wheel    3 Jan  1  2020 Current -> 2.7
% pwd
/System/Library/Frameworks/Python.framework/Versions

There seems to be 2 installed locations for python in Mac

/Library/Frameworks/Python.framework/Versions
/System/Library/Frameworks/Python.framework/Versions

How can I reinstall python 2.7 or say reinstate it if its unlinked ?

like image 452
Axil Avatar asked Nov 01 '25 22:11

Axil


1 Answers

It gets harder and harder to use Python 2.7. Here are the 3 last methods I used, only the last works now.

Miniconda2, stopped working

Until recently I was using Miniconda2 for Python 2.7, but they also just stopped supporting Python 2.7.

Old version of a Brew formula, stopped working

You can still download and old version of a Brew formula and install Python 2.7.

cd ~

wget https://raw.githubusercontent.com/Homebrew/homebrew-core/86a44a0a552c673a05f11018459c9f5faae3becc/Formula/[email protected]

brew install [email protected]

Native macOS Python 2.7.16 with pip and virtual environment, still working

I was able to setup a working Python 2.7 environment in this way by reusing the native Python 2.7.16

  • Install pip manually
  • Setup a virtual environment
  • Install dependencies with pip in virtual environment

Here are the install steps:

wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
python get-pip.py
pip install virtualenv
~/Library/Python/2.7/bin/pip  install virtualenv
virtualenv --python=/usr/bin/python venv
source venv/bin/activate

This is still working, but I am now strongly motivated to port to Python 3.x.

like image 171
Sami Badawi Avatar answered Nov 03 '25 18:11

Sami Badawi