Centos 7 安装pyenv及python 3.8+版本
安装必要依赖
yum -y install gcc make patch gdbm-devel openssl-devel sqlite-devel readline-devel zlib-devel bzip2-devel git
Pyenv安装
curl https://pyenv.run | bash
配置pyenv到path环境变量
安装完成后会看到最后的内容为:
WARNING: seems you still have not added 'pyenv' to the load path.
# Load pyenv automatically by appending
# the following to
# ~/.bash_profile if it exists, otherwise ~/.profile (for login shells)
# and ~/.bashrc (for interactive shells) :
export PYENV_ROOT="$HOME/.pyenv"
[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
# Restart your shell for the changes to take effect.
# Load pyenv-virtualenv automatically by adding
# the following to ~/.bashrc:
eval "$(pyenv virtualenv-init -)"
修改用户目录下的.bash_profile
文件确保用户登录时初始化pyenv
cat << 'EOF' >> .bash_profile
# Load pyenv automatically by appending
# the following to
# ~/.bash_profile if it exists, otherwise ~/.profile (for login shells)
# and ~/.bashrc (for interactive shells) :
export PYENV_ROOT="$HOME/.pyenv"
[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
# Restart your shell for the changes to take effect.
# Load pyenv-virtualenv automatically by adding
# the following to ~/.bashrc:
eval "$(pyenv virtualenv-init -)"
EOF
重新加载.bash_profile
文件
source .bash_profile
使用pyenv安装python3.8+版本报错openssl 1.1.1问题
安装openss11依赖
yum install openssl11-devel
yum swap openssl-devel openssl11-devel
安装前指定使用的openssl
RHEL6:
CPPFLAGS=-I/usr/include/openssl \
LDFLAGS=-L/usr/lib64 \
pyenv install -v 3.4.3
CentOS 7 with OpenSSL 1.1.1:
CPPFLAGS="$(pkg-config --cflags openssl11)" \
LDFLAGS="$(pkg-config --libs openssl11)" \
pyenv install -v 3.10.6
Arch Linux:
LDFLAGS="-L/usr/lib/openssl-1.0" \
CPPFLAGS="-I/usr/include/openssl-1.0" \
pyenv install -v 3.4.3
If you installed openssl with macports:
CPPFLAGS="-I/opt/local/include/" \
LDFLAGS="-L/opt/local/lib/" \
pyenv install -v 3.4.3
网友评论