大约 1 分钟
推荐直接用uv
Update the python
When you can connect to github
Ours environment need python 3.8+. Use the pyenv to update the version.
In CentOS/OpenEuler like this:
curl https://pyenv.run | bash
pyenv update
pyenv install 3.13.0
pyenv global 3.13.0
In Windows like this:pyenv for Windows | pyenv-win (Pip)
`pip install pyenv-win --target %USERPROFILE%\\.pyenv`
And set the envrionment path.
Variable | Value |
---|---|
PYENV | C:\Users\my_pc.pyenv\pyenv-win |
PYENV_HOME | C:\Users\my_pc.pyenv\pyenv-win |
PYENV_ROOT | C:\Users\my_pc.pyenv\pyenv-win |
Path | C:\Users\my_pc.pyenv\pyenv-win\bin C:\Users\my_pc.pyenv\pyenv-win\shims |
(Powershell)
Invoke-WebRequest -UseBasicParsing -Uri "https://raw.githubusercontent.com/pyenv-win/pyenv-win/master/pyenv-win/install-pyenv-win.ps1" -OutFile "./install-pyenv-win.ps1"; &"./install-pyenv-win.ps1"
[System.Environment]::SetEnvironmentVariable('PYENV',$env:USERPROFILE + "\.pyenv\pyenv-win\","User")
[System.Environment]::SetEnvironmentVariable('PYENV_ROOT',$env:USERPROFILE + "\.pyenv\pyenv-win\","User")
[System.Environment]::SetEnvironmentVariable('PYENV_HOME',$env:USERPROFILE + "\.pyenv\pyenv-win\","User")
[System.Environment]::SetEnvironmentVariable('path', $env:USERPROFILE + "\.pyenv\pyenv-win\bin;" + $env:USERPROFILE + "\.pyenv\pyenv-win\shims;" + [System.Environment]::GetEnvironmentVariable('path', "User"),"User")
When can not
CentOS/OpenEuler
sudo dnf install make gcc gcc-c++ zlib zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel xz xz-devel libffi-devel -y
Download source and compile python
# sudo wget https://www.python.org/ftp/python/3.10.10/Python-3.10.10.tgz
sudo wget https://mirrors.huaweicloud.com/python/3.10.10/Python-3.10.10.tgz
sudo tar -zxvf Python-3.10.10.tgz
cd Python-3.10.10/
sudo ./configure --prefix=/usr/local/python3.10.10 --enable-optimizations
sudo make -j4 && sudo make -j4 install
Create new link
mv -f /usr/bin/python /usr/bin/python.bak
mv -f /usr/bin/pip /usr/bin/pip.bak
ln -sf /usr/local/python3.10.10/bin/python3 /usr/bin/python
ln -sf /usr/local/python3.10.10/bin/python3.10 /usr/bin/python3
ln -sf /usr/local/python3.10.10/bin/pip3 /usr/bin/pip
ln -sf /usr/local/python3.10.10/bin/pip3 /usr/bin/pip3
Test the version
python -V