Steps for upgrading Python2.7 to Python3.5 in Mac: python2.7python3.5
Download Python3.5 for Mac and install it step by step
The default installation path is: /Library/Frameworks/Python.framework/Versions/3.5/
We strongly recommend that you do not directly use sudo ln-s (it will directly overwrite the original link of the system and cause problems in calling the software that comes with python). Although it is safer to modify path variable, but it is not necessary for your needs.
To meet your requirements as follows:
Enter the "python" command in the terminal to run the 3.5 py version?
Add an alias directly in. profile. If your Terminal running shell is bash (default), you can modify ~ /. Bash_profile, add downstream (the specific path depends on your python3 installation path ):
Copy codeThe Code is as follows:
Alias python = "/Library/Frameworks/Python. framework/Versions/3.5/bin/python3.5"
Restart Terminal or directly
source ~/.bash_profile
The following is the. bash_profile content in my Mac user's home directory for your reference.
Alias ls = 'LS-G' --> ls: alias ll = 'LS-l' # unalias ls # unalias ll # export CLICOLOR = 1 export LSCOLORS = exfxaxdxcxegedabagacad ---> set the display directory and the export PATH with color of the file to $ PATH: /usr/local/MySQL/bin:/Library/Frameworks/Python. framework/Versions/3.5/binexport PATH # Setting PATH for Python 3.5 # The original version is saved in. bash_profile.pysaveexport PATH = $ PATH:/Library/Frameworks/Python. framework/Versions/3 . 5/bin: alias python = "/Library/Frameworks/Python. framework/Versions/3.5/bin/python3.5 "~
If you want to comment out the last line in. bash_profile for Python2.7, use Python3.5.2 to take effect of the last line of. bash_proflle. This is simple and convenient. I like it.
The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.