Python2.7 upgrade Python3.5 steps for Mac OS X10.12.4 installation

Source: Internet
Author: User

Mac OS X10.12 default with Python2.7, but now Python3.5 out, if you want to use the latest version, quickly upgrade it. The basic steps are as follows

1th Step: Download Python3.3

There's a setup program under Windows and Mac OS X that downloads that 64-bit installer.

2nd step: Install the downloaded img file, after the installation of the following directory:

Copy CodeThe code is as follows:
/library/frameworks/python.framework/versions/3.5

3rd step: Move Python's installation directory

The original installation directory is shown in step 2nd, but all Python
/system/library/frameworks/python.framework/versions
directory, so it is best to use the following command to move, of course, do not move. However, some of the paths in the later steps need to be modified.
sudo mv/library/frameworks/python.framework/versions/3.5/system/library/frameworks/python.framework/versions
4th Step: Change the user group of the Python installation directory to wheel

Copy CodeThe code is as follows:
sudo chown-r root:wheel/system/library/frameworks/python.framework/versions/3.3
python2.7 user Group is wheel,3.5 also divert it!

4th Step: Modify the symbolic link of the current installation directory of Python

There is a current in the/system/library/frameworks/python.framework/versions/directory, which is a directory symbolic link that points to the currently Python version. Originally pointing to 2.7, now points to 3.5. Therefore, the current should be removed first. Then re-establish the current symbolic link, with the following command:

Copy CodeThe code is as follows:
sudo rm/system/library/frameworks/python.framework/versions/current
sudo ln-s/system/library/frameworks/python.framework/versions/3.5/system/library/frameworks/python.framework/ Versions/current

5th step: Delete the old command symbolic link

In the/usr/bin directory there are 4 Python command symbolic links, using the following command to first remove

Copy CodeThe code is as follows:
sudo rm/usr/bin/pydoc
sudo rm/usr/bin/python
sudo rm/usr/bin/pythonw
sudo rm/usr/bin/python-config

6th step: Re-establish new command symbolic links

Use the following command to re-establish the symbolic link removed in step 6th, all pointing to Python3.5.

Copy CodeThe code is as follows:
sudo ln-s/system/library/frameworks/python.framework/versions/3.5/bin/pydoc3.5/usr/bin/pydoc
sudo ln-s/system/library/frameworks/python.framework/versions/3.5/bin/python3.5/usr/bin/python
sudo ln-s/system/library/frameworks/python.framework/versions/3.5/bin/pythonw3.5/usr/bin/pythonw
sudo ln-s/system/library/frameworks/python.framework/versions/3.5/bin/python3.5m-config/usr/bin/python-config

7th step: Update the path in the/root/.bash_profile file

Copy CodeThe code is as follows:
CD ~
Vim. Bash_profile

Insert the following content in the. bash_profile

Copy CodeThe code is as follows:
# Setting PATH for Python 3.5
# The orginal version is saved in. bash_profile.pysave
Path= "/system/library/frameworks/python.framework/versions/3.5/bin:${path}"
Export PATH

OK, now reboot the console, then execute Python--version, and get Python 3.5. If you are in a program, you need to get the Python version using the following code

Copy CodeThe code is as follows:
Import Platform
Print (Platform.python_version ())

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

You can now use the latest Python3.5.

Python2.7 upgrade Python3.5 steps for Mac OS X10.12.4 installation

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.