I had python
(which was python2) and python3
both installed on my Mac OS High Sierra. I was doing some installations in which I ran:
brew install automake
brew install doxygen
brew install ant
and during these processes, my brew must have been updated as well. And now, I realised that python3
, which has been perfectly working for the last few months, just vanished.
> brew update
Already up-to-date.
> brew install python
Error: python 2.7.14 is already installed
To upgrade to 3.6.4_4, run `brew upgrade python`
> brew install python3
Error: python 2.7.14 is already installed
To upgrade to 3.6.4_4, run `brew upgrade python`
And now, I do not seem to be able to reinstall python3
back. What's, more, I am afraid that if I run brew upgrade python
, I will lose access to python2.
PS : I've noticed the absence of python3
when I opened my terminal and it said:
Last login: Sat Mar 10 15:16:43 on ttys002
virtualenvwrapper_run_hook:12: no such file or directory: /usr/local/bin/python3
virtualenvwrapper.sh: There was a problem running the initialization hooks.
If Python could not import the module virtualenvwrapper.hook_loader,
check that virtualenvwrapper has been installed for
VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3 and that PATH is
set properly.
Any ideas on how to fix this or what might have been the cause of the problem?
The reason is explained here: https://brew.sh/2018/01/19/homebrew-1.5.0/
I would suggest to add the new formula: brew install python@2
Running brew info python@2
you will get the location of the package installed:
/usr/local/Cellar/python@2/2.7.14_3
Keep in mind that python@2 is a "keg-only" formula, which means that it's not linked into /usr/local . At this point, depending on your needs you should force a link to it if necessary. Try first a --dry-run
to understand what will happen:
brew link --force --dry-run python@2
If you do not want to run the brew link command, you always create a convenient symbolic link (you will have to keep the link updated in case you run an update of the formula):
ln -s ../Cellar/python@2/2.7.14_3/bin/python python2
Bottom line is that homebrew started considering python2 obsolete.
In case someone else is having the same problem, brew upgrade python
does not break anything. I ran it and I still have access to Python 2 and additionally, I got Python 3. Also, all old libraries remain pre-installed
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.