How to upgrade Python2.7 under Mac OS X10.9 to the latest Python3.3.3

Source: Internet
Author: User


Mac OS X10.9 comes with Python2.7 by default, but now Python3.3.3 is available. If you want to use the latest version, upgrade it. The basic steps are as follows.

Step 2: Download Python3.3

As follows:

Python3.3

There are installation programs in windows and mac OS x. Download the 64-bit installation program (it is estimated that 32-bit mac OS x is not used now)

 

Step 2:

Install and download the imgfile. 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 pythons are in

/System/Library/Frameworks/Python.framework/Versions

In the directory, it is best to use the following command to move it, of course, it can be moved. However, some of the paths in the later steps need to be modified.

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

The user group of python2.7 is wheel, 3.3 also take the gourd painting!
Step 5: Modify the symbolic link to the Python current installation directory
There is a Current in the /System/Library/Frameworks/Python.framework/Versions/ directory, which is a directory symbolic link to the current Python version. Originally pointing to 2.7, it now points to 3.3. So you should delete Current first. Then re-establish the Current symbol link, the command is 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 6: Remove the old command symbolic link

There are 4 symbolic links to the python command in the /usr/bin directory, which are removed first using the following command.

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

Step 7: Re-create a new command symbolic link

Re-create the symbolic links removed in step 6 using the following commands, all pointing to Python 3.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 8: Update the path in the /root/.bash_profile file



cd ~
vim .bash_profile 

Insert the following content in .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 and execute python --version to get Python 3.3.3. If you are in the program, you need to use the following code to get the python version.

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


import platform
print(platform.python_version())
You can now use the latest Python 3.3.3.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.