wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz
tar -xzvf Python-3.7.0.tgz
cd Python-3.7.0
ubuntu: apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \ libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \ xz-utils tk-dev libffi-dev openssl centos: yum install -y zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel xz xz-devel libffi-devel
./configure --prefix=/usr/local
make make install
python # python2 python3 # python3
pip # python2 pip3 # python3
(注意:升级pip先升级pip3再用pip2升级pip2,否则pip会被pip3替换)
pip3 install virtualenv virtualenv py2 -p python virtualenv py3 -p python3
# linux ,mac curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash # mac brew install pyenv
pyenv install -v 3.7.2 pyenv install -v 2.7.15
# 当前shell激活2.7 pyenv shell 2.7.15 python # python2.7 # 永久使用2.7 pyenv global 2.7.15 # 3.7同理 pyenv shell 3.7.2 python # python3.7
更多参考pyenv文档
发表评论 (对文章评论)