Centos7安裝新版本python3.10
簡單說明
- Python2.7.5是CentOS 7默認安裝的版本;
- Python3.6.8是CentOS 7中可以通過默認repo安裝到的最新版本;
如果簡單使用,默認的python可能已經夠用,但是如果使用python3版本的話,還是推薦升級到3的較高版本3.7/3.8/3.9/3.10/3.11...(不推薦3.6)。
安裝過程
官方源碼包下載地址:https://www.python.org/downloads/source/
1. 安裝必要的依賴
yum groupinstall "Development Tools"
yum install openssl-devel bzip2-devel libffi-devel
2. 下載源碼包
wget https://www.python.org/ftp/python/3.10.9/Python-3.10.9.tgz
3. 解壓進入
tar zxvf Python-3.10.9.tgz
cd Python-3.10.9
4. 編譯安裝
./configure --prefix=/usr/local/python310
make && make install
5. 加入系統路徑
[臨時]
export PATH=/usr/local/python310/bin:$PATH
[永久]
echo 'export PATH=/usr/local/python310/bin:$PATH' >> /etc/profile
source /etc/profile
6. 檢查python版本
python3 -V
6. 下載安裝不了依賴包,解決辦法
pip安裝出錯 Could not fetch URL,There was a problem confirming the ssl certificate:HTTPSConnection
#修改鏡像源
vim ~/.pip/pip.conf
[global]
index-url = http://mirrors.aliyun.com/pypi/simple
extra-index-url = http://mirrors.aliyun.com/pypi/simple
[install]
trusted-host =
mirrors.aliyun.com
pypi.douban.com
pypi.tuna.tsinghua.edu.cn
pypi.mirrors.ustc.edu.cn
mirrors.ustc.edu.cn
mirrors.bfsu.edu.cn
pypi.hustunique.com

浙公網安備 33010602011771號