# 参考链接 https://www.jianshu.com/p/8b4333b9b55e
# 安装 pyenv
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bashrc
exec "$SHELL"
# 基于pyenv安装python环境
pyenv install --list
pyenv install 3.7.3
pyenv versions
# 安装 pyenv-virtualenv
git clone https://github.com/pyenv/pyenv-virtualenv.git $(pyenv root)/plugins/pyenv-virtualenv
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc
exec $SHELL
# 创建虚拟环境
pyenv virtualenv 3.7.3 my-env
pyenv activate my-env
pyenv deactivate
# 设置pip源
mkdir -p /root/.pip
touch /root/.pip/pip.conf
cat << EOF > /root/1.test
[global]
index-url=http://pypi.douban.com/simple/
[install]
trusted-host=pypi.douban.com
EOF
# 安装模块
pyenv activate my-env
pip install tensorflow
pip list|grep tensorflow
网友评论