Details of steps to upgrade Python3.3 for Python2.7 installed in Mac OS X10.9

  • 2020-04-02 13:14:51
  • OfStack

Step 1: download Python3.3 from the official website

There is an installer for Windows and MAC OS x. Download the 64-bit installer

Step 2: install the downloaded img file. The directory after installation is as follows:


/Library/Frameworks/Python.framework/Versions/3.3

Step 3: move the python installation directory

The original installation directory is shown in step 2, but all python is there
/ System/Library/Frameworks/Python framework/Versions
Directory, so it is best to use the following command to move, of course not to move. But some of the paths in the next step need to be changed.
Sudo mv/Library/Frameworks/Python framework Versions / 3.3 / System/Library/Frameworks/Python framework/Versions
Step 4: change the user group of the Python installation directory to wheel


sudo chown -R root:wheel /System/Library/Frameworks/Python.framework/Versions/3.3

Python2.7's user group is wheel, so do 3.3!

Step 4: modify the symbolic link to the Python current installation directory

In/System/Library/Frameworks/Python framework Versions/directory has a Current, this is a record the symbolic links, pointing to the Current Python version. Instead of pointing to 2.7, it now points to 3.3. So delete Current first. Then re-establish the Current symbolic link, as follows:


sudo rm /System/Library/Frameworks/Python.framework/Versions/Current
sudo ln -s /System/Library/Frameworks/Python.framework/Versions/3.3 /System/Library/Frameworks/Python.framework/Versions/Current

Step 5: remove the old command symbolic link

There are symbolic links to four python commands in the /usr/bin directory. Use the following command to remove them first


sudo rm /usr/bin/pydoc
sudo rm /usr/bin/python
sudo rm /usr/bin/pythonw
sudo rm /usr/bin/python-config

Step 6: re-establish a new command symbolic link

Re-create the symbolic links removed in step 6 using the following command, which both point to Python3.3.


sudo ln -s /System/Library/Frameworks/Python.framework/Versions/3.3/bin/pydoc3.3 /usr/bin/pydoc
sudo ln -s /System/Library/Frameworks/Python.framework/Versions/3.3/bin/python3.3 /usr/bin/python
sudo ln -s /System/Library/Frameworks/Python.framework/Versions/3.3/bin/pythonw3.3 /usr/bin/pythonw
sudo ln -s /System/Library/Frameworks/Python.framework/Versions/3.3/bin/python3.3m-config /usr/bin/python-config

Step 7: update the path in the /root/.bash_profile file


cd ~
vim .bash_profile 

Insert the following in the.bash_profile


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

Ok, now restart the Console, then execute python-version, and you get python 3.3.3. If you are in a program, you need to use the following code to get the python version


import platform
print(platform.python_version())

If you still use an IDE such as PyDev, you still need to update the path.

You are now ready to use the latest Python3.3.3.


Related articles: