Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to link home brew python version and set it as default

I just switched from MacPorts to HomeBrew. After installing all the required XCode versions and other software I tried installing python using homebrew: I think it successfully installed, but when I do which python it still shows me 2.7.3 which I think is the version shipped with Mountain Lion.

which python /usr/local/bin/python  python --version Python 2.7.3 

so I tried to install again

brew install python --framework --universal Warning: python-2.7.5 already installed, it's just not linked 

But it says python 2.7.5 already install and not linked, I tried to do brew link python

That led me to following message so, I have no idea what I should be doing:

Linking /usr/local/Cellar/python/2.7.5... Warning: Could not link python. Unlinking...

Error: Could not symlink file: /usr/local/Cellar/python/2.7.5/bin/smtpd2.py Target /usr/local/bin/smtpd2.py already exists. You may need to delete it. To force the link and overwrite all other conflicting files, do:   brew link --overwrite formula_name  To list all files that would be deleted:   brew link --overwrite --dry-run formula_name 
like image 980
add-semi-colons Avatar asked Oct 13 '13 01:10

add-semi-colons


People also ask

How do I switch between installed Python versions?

To switch between python version over the all users, we can use update-alternatives command. We will set priority of each version using update-alternatives. Python executable with the highest priority will be used as default python version. Here I set the priority of python 2.7, 3.5, 3.6, 3.7, 3.8 as 1, 2, 3, 4, 5.


1 Answers

After installing python3 with brew install python3 I was getting the error:

Error: An unexpected error occurred during the `brew link` step The formula built, but is not symlinked into /usr/local Permission denied @ dir_s_mkdir - /usr/local/Frameworks Error: Permission denied @ dir_s_mkdir - /usr/local/Frameworks 

After typing brew link python3 the error was:

Linking /usr/local/Cellar/python/3.6.4_3... Error: Permission denied @ dir_s_mkdir - /usr/local/Frameworks 

To solve the problem:

sudo mkdir -p /usr/local/Frameworks sudo chown -R $(whoami) /usr/local/* brew link python3 

After this, I could open python3 by typing python3 👍

(From https://github.com/Homebrew/homebrew-core/issues/20985)

like image 130
lenooh Avatar answered Sep 22 '22 10:09

lenooh