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環(huán)境變量
安裝完成后會(huì)看到最后的內(nèi)容為:
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
文件確保用戶登錄時(shí)初始化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+版本報(bào)錯(cuò)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:
export CPPFLAGS="$(pkg-config --cflags openssl11)"
export LDFLAGS="$(pkg-config --libs openssl11)"
pyenv install -v 3.10.6
或者
export CFLAGS="-I /usr/local/openssl-1.1.1w/include"
export LDFLAGS="-I /usr/local/openssl-1.1.1w/lib"
env
pyenv install 3.10.11
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