一,python官网:
https://www.python.org/
下载页面:
https://www.python.org/downloads/source/
如图:
二,安装
1,下载:
wget从命令行下载:
liuhongdi@lhdpc:/usr/local/source/python$ wget https://www.python.org/ftp/python/3.12.5/Python-3.12.5.tgz
2,解压:
liuhongdi@lhdpc:/usr/local/source/python$ tar -zxvf Python-3.12.5.tgz
3,安装:
配置:
liuhongdi@lhdpc:/usr/local/source/python$ cd Python-3.12.5/
liuhongdi@lhdpc:/usr/local/source/python/Python-3.12.5$ ./configure --prefix=/usr/local/soft/python3.12.5 --enable-optimizations
编译并安装:
liuhongdi@lhdpc:/usr/local/source/python/Python-3.12.5$ make && make install
查看效果:
liuhongdi@lhdpc:/usr/local/source/python/Python-3.12.5$ /usr/local/soft/python3.12.5/bin/python3 --version
Python 3.12.5
三,配置venv
1,创建venv
liuhongdi@lhdpc:/data/work/python$ mkdir xiaoqu
liuhongdi@lhdpc:/data/work/python$ cd xiaoqu/
liuhongdi@lhdpc:/data/work/python/xiaoqu$ /usr/local/soft/python3.12.5/bin/python3 -m venv venv
2,进入venv环境
liuhongdi@lhdpc:/data/work/python/xiaoqu$ source venv/bin/activate
(venv) liuhongdi@lhdpc:/data/work/python/xiaoqu$ python3 --version
Python 3.12.5
3,安装需要的第三方库:
安装前:
(venv) liuhongdi@lhdpc:/data/work/python/xiaoqu$ pip3 list
Package Version
------- -------
pip 24.2
安装
(venv) liuhongdi@lhdpc:/data/work/python/xiaoqu$ pip3 install requests
Collecting requests
Downloading requests-2.32.3-py3-none-any.whl.metadata (4.6 kB)
Collecting charset-normalizer<4,>=2 (from requests)
Downloading charset_normalizer-3.3.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (33 kB)
Collecting idna<4,>=2.5 (from requests)
Downloading idna-3.7-py3-none-any.whl.metadata (9.9 kB)
Collecting urllib3<3,>=1.21.1 (from requests)
Downloading urllib3-2.2.2-py3-none-any.whl.metadata (6.4 kB)
Collecting certifi>=2017.4.17 (from requests)
Downloading certifi-2024.7.4-py3-none-any.whl.metadata (2.2 kB)
Downloading requests-2.32.3-py3-none-any.whl (64 kB)
Downloading certifi-2024.7.4-py3-none-any.whl (162 kB)
Downloading charset_normalizer-3.3.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (141 kB)
Downloading idna-3.7-py3-none-any.whl (66 kB)
Downloading urllib3-2.2.2-py3-none-any.whl (121 kB)
Installing collected packages: urllib3, idna, charset-normalizer, certifi, requests
Successfully installed certifi-2024.7.4 charset-normalizer-3.3.2 idna-3.7 requests-2.32.3 urllib3-2.2.2
安装后查看效果:
(venv) liuhongdi@lhdpc:/data/work/python/xiaoqu$ pip3 list
Package Version
------------------ --------
certifi 2024.7.4
charset-normalizer 3.3.2
idna 3.7
pip 24.2
requests 2.32.3
urllib3 2.2.2
再装一个shapely
(venv) liuhongdi@lhdpc:/data/work/python/xiaoqu$ pip3 install shapely
Collecting shapely
Downloading shapely-2.0.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (7.0 kB)
Collecting numpy<3,>=1.14 (from shapely)
Downloading numpy-2.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (60 kB)
Downloading shapely-2.0.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.5 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.5/2.5 MB 265.9 kB/s eta 0:00:00
Downloading numpy-2.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.0 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 16.0/16.0 MB 154.7 kB/s eta 0:00:00
Installing collected packages: numpy, shapely
Successfully installed numpy-2.1.0 shapely-2.0.5
查看效果:
(venv) liuhongdi@lhdpc:/data/work/python/xiaoqu$ pip3 list
Package Version
------------------ --------
certifi 2024.7.4
charset-normalizer 3.3.2
idna 3.7
numpy 2.1.0
pip 24.2
requests 2.32.3
shapely 2.0.5
urllib3 2.2.2
标签:kB,python3.12,Downloading,python,linux,liuhongdi,whl,lhdpc,ubuntu From: https://www.cnblogs.com/architectforest/p/18367837