In Mac the steps of upgrading Python2.7 to Python3.5 are explained in detail

  • 2020-05-30 20:32:16
  • OfStack

Download Python3.5 for Mac 1 step by step

The default path for installation is: /Library/Frameworks/Python.framework/Versions/3.5/

It is strongly recommended that you do not directly sudo ln-s (it will overwrite the system's original link and cause problems in calling the software that comes with python). Modifying path variable is safe, but not necessary for your needs.

Want to fulfill your following requirements

Enter the "python" command directly in the terminal and py version 3.5 will be run.

Just add one alias to the.profile. If your Terminal is running shell is bash(the default), you can modify ~/.bash_profile and add the downstream (the specific path depends on your python3 installation path) :


alias python="/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5"

Then restart 1 hit Terminal or directly


source ~/.bash_profile

Below is the.bash_profile content in my Mac user's home directory for your reference


alias ls='ls -G' -->ls  The file with color is displayed 

alias ll='ls -l' 

#unalias ls 

#unalias ll

#export CLICOLOR=1

export LSCOLORS=exfxaxdxcxegedabagacad   ---> Set the color of the displayed directory and files 

export PATH=$PATH:/usr/local/MySQL/bin:/Library/Frameworks/Python.framework/Versions/3.5/bin

export PATH
# Setting PATH for Python 3.5

# The original version is saved in .bash_profile.pysave

export 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 Python2.7, just comment out the last line of.bash_profile, and if you want Python3.5.2, just comment out the last line of.bash_proflle.


Related articles: