# 2.7
yum -y install python-setuptools
easy_install -i https://pypi.tuna.tsinghua.edu.cn/simple pip
# pyenv
yum -y install gcc zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel tk-devel libffi-devel xz wget
wget https://github.com/pyenv/pyenv/archive/v1.2.21.tar.gz
useradd pyuser -s /sbin/nologin
chown pyuser:pyuser pyenv-1.2.21.tar.gz
mv pyenv-1.2.21.tar.gz /home/pyuser/
su - pyuser -s /bin/bash
tar xf pyenv-1.2.21.tar.gz
mv pyenv-1.2.21 .pyenv
chown -R pyuser.pyuser .pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> /home/pyuser/.bash_profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> /home/pyuser/.bash_profile
echo 'eval "$(pyenv init -)"' >> /home/pyuser/.bash_profile
exec "$SHELL"
# 或ctrl+d 退出重新登陆
which pyenv
v=3.7.8;wget https://npm.taobao.org/mirrors/python/$v/Python-$v.tar.xz -P ~/.pyenv/cache/;pyenv install $v
mkdir py3 && cd py3
pyenv local 3.7.8
python -V
which python
# crontab中也可以使用
#~/.pyenv/shims/python
pip -V
# 设置镜像
cat > ~/.pip/pip.conf << EOF
[global]
index-url = https://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
EOF
CentOS下使用pyenv搭建python3环境
最新推荐文章于 2023-12-18 21:54:10 发布