Installation of Ipython under Mac system supports Python2 and Python3 respectively

Source: Internet
Author: User

    • Operating system: Mac10.11.5
    • python2.7.13
    • python3.6.1

Install Python2:

Install python

Install Python3:

Install Python3

At this point, the command line input Python3 opens the Python3, and the input Python opens the Python2.

Installing Ipython with PIP

sudo Install Ipython sudo Install Ipython

Install Ipython with PIP is installed in the Python2 site-packages , the same PIP3 is installed in Python3 site-packages.

Enter the /usr/local/bin directory, you can see the ipython file, open with VI:

sudo VI Ipython

#!/usr/local/opt/python/bin/python2.7#-*-coding:utf-8-*-ImportReImportSYS fromIPythonImportStart_ipythonif __name__=='__main__': sys.argv[0]= Re.sub (r'(-script\.pyw?| \.exe)? $',"', sys.argv[0]) Sys.exit (Start_ipython ())
#!/usr/local/opt/python/bin/python2.7 This directory is the version that points to Python,
For example I want to be directed into Python3 can modify the #!/usr/local/opt/python3/bin/python3.6
So ipython this command open Ipython the Python version pointed to is Python3. For convenience we can copy this file for Ipython3, ipython3 This command file point to Python3 version, so in the terminal input Ipython Open is python2, input Ipython3 Open is Python3, is not very convenient!

Installation of Ipython under Mac system supports Python2 and Python3 respectively

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.