2

I would like to update Python 2.7 to Python 3.4. Currently, I am using Mac OS X 10.9.5.

I have used Homebrew to install Python 3.4. However, when I used python -V to check the version of my Python in the terminal, it still appears to be on the 2.7 version.

enter image description here

Anybody have any idea as for why this is?

Also, I have tried to follow the directions of this article to update to Python 3 (see the second half of the article). Yet my system cannot find this file: /System/Library/Frameworks/Python.framework/Versions/3.4

2
  • 2
    Because you've installed python3, not "updated" python (which you shouldn't do - changing the system Python could lead to all kinds of problems). Try python3 -V. Commented Sep 9, 2015 at 10:36
  • @jonrsharpe According to the answer below, I can make a symlink from python to python3. Would this lead to problems also? Commented Sep 10, 2015 at 9:05

1 Answer 1

3

First install python3 using homebrew.

brew install python3

Second you may want to use python3 as default change the ~/.bash_aliases to point to python3. This can be done by adding the following command in the ~/.bash_aliases.

alias python='python3'

now all the python command gets referred to python3 by default.

EDIT 1: Try running the following command.

/usr/bin/env python3  

This will make python3 as default environment for python executables.

EDIT 2: [Like suggested by robert] try making a symlink from python to python3. this makes python3 as default environment in all shells.

Sign up to request clarification or add additional context in comments.

3 Comments

This will only work when python is invoked from bash. I suggest actually running python3 or making a symlink from python to python3 in /usr/local/bin.
Try running the following command. /usr/bin/env python3 . This will make python3 as default python executable environment
Yeah @robert that will be a better solution. I will update my answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.