The problem

Source of problem

  • On MacOS, Python is installed by default, version 2.7
  • Python allows multiple Versions of Python to exist on the same system
  • By default, python2.7 is enabled when you run the Python command on the terminal. To use python3, you need to use the python3 command. To directly use the Python command to enable python3, you need to set the alias

The problem

  • After configuring the environment variables in bash_profile, configure the alias
  • Cause problems: The alias takes effect only if bash_profile is executed on the terminal, and the command is invalidated each time iTerm2 is restarted
source ~/.bash_profile
Copy the code

The solution

  • Writing the alias configuration from bash_profile to ZSHRC eliminates the problem of invalidation of aliases after iTerm2 restarts
vi ~/.zshrc
Copy the code

The principle of

  • The alias will take effect only if bash_profile:source ~/. Ba sh_profile is executed on the terminal each time it restarts
  • Since ZSHRC files are automatically executed when iTerm2 is started,
  • The configurations in ZSHRC are global

Attention!

  • Note the shell version used:
    • ZSH corresponds to ZSHRC
    • Bash corresponds to BASIC
  • In order to resolve the alias restart terminal failure, the Internet solution is to add a configuration in bashrc
  • Then I thought of the ZSHRC file I had used before
  • It turned out that I had changed the terminal shell from bash to ZSH when configuring oh-my-zsh, which worked perfectly with ZSHRC