Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set default Python version in terminal on OS X 10.6.8?

Tags:

I just downloaded python 2.7 on my mac which runs OS X 10.6.8. The previous version of python installed was 2.6.

When I type python in the terminal it opens python version 2.6. I want it to open python 2.7

How do I make Python 2.7 open by default?

like image 513
CodeKingPlusPlus Avatar asked Mar 08 '13 02:03

CodeKingPlusPlus


People also ask

How do I make Python 3.7 default on Mac?

Open the terminal (bash or zsh) whatever shell you are using. Install python-3 using Homebrew (https://brew.sh). Look where it is installed. Change the default python symlink to the version you want to use from above.

What is the default version of Python on Mac?

Use Python 3 as the macOS default Python's website has a macOS Python 3 installer we can download and use. If we use the package installation, a python3 fill will be available in /usr/local/bin/.


1 Answers

The python.org installers for Python 2.x on OS X by default modify shell profiles (for the standard shells like bash and csh) to add its framework bin directory to the front of your shell path. Assuming you did not deselect the option during installation, there should now be the following in your .bash_profile file.

# Setting PATH for Python 2.7 # The orginal version is saved in .profile.pysave PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}" export PATH 

But this profile is only executed by default when you launch a new terminal window; it won't apply to existing terminal sessions. So make sure you open a new one and then try again. If you are using a different shell, you may need to modify that shell's startup to do the equivalent.

The python.org installers for Python 3.x on OS X do not select the shell script modification option by default. You can enable it at installation or you can later run the Update Shell Profile.command file in the corresponding Python x.x folder in the Applications folder. Or you can just manually edit the right profile.

like image 65
Ned Deily Avatar answered Oct 11 '22 03:10

Ned Deily