Last active
March 7, 2020 11:32
-
-
Save caliburn1994/428525ad57d76f20006b26c514d837f9 to your computer and use it in GitHub Desktop.
Ubuntu install a specific python version. Ubuntu下安装特定版本的python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 依赖工具 | |
# 参考:https://github.com/pyenv/pyenv/wiki/common-build-problems | |
echo "下载依赖工具" | |
sudo 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 liblzma-dev python-openssl git | |
# ↑和平台有关 | |
# ↓与平台无关 | |
echo "安装pyenv" | |
# 下载 | |
git clone https://github.com/pyenv/pyenv.git ~/.pyenv | |
# 环境变量 | |
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile | |
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile | |
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bash_profile | |
#激活 | |
source ~/.bash_profile | |
#安装版本 | |
pyenv install 3.7.4 | |
# 基本信息 | |
echo "根目录为:$(pyenv root)" | |
echo "查看已安装版本" | |
pyenv versions | |
echo "切换版本命令" | |
echo "pyenv global 3.7.4 " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment