Python default version switch

Mac comes with python2.7 version, but I downloaded a 3.7 version (the downloaded version is installed by default in  /Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 )

To switch to version 3.7, just add an alias to .profile, as follows

// Terminal input 
open ~/.bash_profile
// Add 
alias python="/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7" at the end of the bash_profile file
// After saving and exiting, enter the restart configuration in the terminal 
source ~/.bash_profile

If you don't need 3.7 and want to use 2.7 that comes with mac, just delete this sentence

// Check the default python version of the system, input 
python - V
 in the terminal // The display is as follows  //Prove that the default version of the system has been switched from 2.7 to 3.7 version
Python 3.7.0b3

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324653069&siteId=291194637