On the Mac Python Multi-Version Switch

1, install Homebrew
https://brew.sh/index_zh-cn.html

2, through the brew installation pyenv
1) command line, enter:
$ brew install pyenv (If you have been stuck in Updating Homebrew press ctrl + c on a jump brew update)

2) In the .bash_profile file in the home directory is added:

vi ~ / .bash_profile added at the end

eval "$(pyenv init -)"

3) command line input, update the environment variable:
$ Source .bash_profile 
Note: if not configured can not switch between the python version.


3, using pyenv installation A Python 3
1) View can be installed version (only version is the official version, the other is a derivative version)
$ Source .bash_profile 

2) install the required version: 
$ pyenv install 3.7.4 -v (see What are some versions can be installed: pyenv install --list)

3) Upon completion of the update the database: 
$ pyenv rehash 

4) Check the system installed version: 
$ pyenv versions 
* number indicates the version of the system currently in use 

5) switching python version 
$ 3.6.2 Global pyenv
$ pyenv Global System

6) confirm the version of python 
python --version

 

4, solve Python command to install with pip slow, mirroring domestic use

There ~ / .pip / pip.conf

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=mirrors.aliyun.com

 

Guess you like

Origin www.cnblogs.com/terrylin/p/12076918.html