Python下载
根据需要下载对应的版本。
![图片[1]-python环境安装部署-秋风落叶](https://wangjian.run/wp-content/uploads/2025/06/20250629234516277-image-1024x338.png)
windows环境安装
按照注意事项:最好自定义路径,且加入到系统环境变量中,其他的都默认走就行。
![图片[2]-python环境安装部署-秋风落叶](https://wangjian.run/wp-content/uploads/2024/02/1707292724-image.png)
![图片[3]-python环境安装部署-秋风落叶](https://wangjian.run/wp-content/uploads/2024/02/1707292855-image.png)
看这个这个页面说明安装成功
![图片[4]-python环境安装部署-秋风落叶](https://wangjian.run/wp-content/uploads/2024/02/1707293160-image.png)
验证安装是否成功
进入到安装目录去执行exe文件
![图片[5]-python环境安装部署-秋风落叶](https://wangjian.run/wp-content/uploads/2024/02/1707293221-image.png)
能够打开说明安装成功,或者执行一个运算也行。
![图片[6]-python环境安装部署-秋风落叶](https://wangjian.run/wp-content/uploads/2024/02/1707293284-image.png)
获取随机数
#获取1-100以内的随机数,random是获取0-1之间的数,round是四舍五入
import random
print(round(random.random()*100))
MAC环境下安装部署
下载后打开文件
![图片[7]-python环境安装部署-秋风落叶](https://wangjian.run/wp-content/uploads/2025/06/20250629234844487-image.png)
![图片[8]-python环境安装部署-秋风落叶](https://wangjian.run/wp-content/uploads/2025/06/20250629234922276-image.png)
![图片[9]-python环境安装部署-秋风落叶](https://wangjian.run/wp-content/uploads/2025/06/20250629234952764-image.png)
![图片[10]-python环境安装部署-秋风落叶](https://wangjian.run/wp-content/uploads/2025/06/20250629235008373-image.png)
![图片[11]-python环境安装部署-秋风落叶](https://wangjian.run/wp-content/uploads/2025/06/20250629235029828-image.png)
![图片[12]-python环境安装部署-秋风落叶](https://wangjian.run/wp-content/uploads/2025/06/20250629235046961-image.png)
![图片[13]-python环境安装部署-秋风落叶](https://wangjian.run/wp-content/uploads/2025/06/20250629235123810-image.png)
![图片[14]-python环境安装部署-秋风落叶](https://wangjian.run/wp-content/uploads/2025/06/20250629235142811-image.png)
![图片[15]-python环境安装部署-秋风落叶](https://wangjian.run/wp-content/uploads/2025/06/20250629235156126-image.png)
至此安装完成。
验证安装结果
![图片[16]-python环境安装部署-秋风落叶](https://wangjian.run/wp-content/uploads/2025/06/20250629235325933-image.png)
MAC下注意事项
命令行敲python是不行的,需要加入对应的版本号,因为环境变量的名字不一样。
![图片[17]-python环境安装部署-秋风落叶](https://wangjian.run/wp-content/uploads/2024/02/20240217223850548-1708180730-截屏2024-02-17-22.37.22.png)
原因如下:
![图片[18]-python环境安装部署-秋风落叶](https://wangjian.run/wp-content/uploads/2024/02/20240217223950492-1708180790-截屏2024-02-17-22.39.14.png)
Linux环境下安装部署
下载地址
https://www.python.org/ftp/python/
旧环境变量
[root@wj ~]# ll /usr/bin/python*
lrwxrwxrwx. 1 root root 7 12月 15 20:56 /usr/bin/python -> python2
lrwxrwxrwx. 1 root root 9 12月 15 20:56 /usr/bin/python2 -> python2.7
-rwxr-xr-x. 1 root root 68600 9月 9 2021 /usr/bin/python2.7
[root@wj ~]# python -V
Python 2.7.5
[root@wj ~]# python2 -V
Python 2.7.5
[root@wj ~]# python2.7 -V
Python 2.7.5
[root@wj ~]#
安装依赖包
yum install zlib zlib-devel libffi-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make wget
下载安装python
wget https://www.python.org/ftp/python/3.10.13/Python-3.10.13.tar.xz
解压编译安装
xz -d Python-3.10.13.tar.xz
tar -xf Python-3.10.13.tar
cd Python-3.10.13
./configure prefix=/usr/local/python3
make && make install
进入安装目录的python3设置软链接
ln -s /usr/local/python3/bin/python3.10 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
查看下新的环境变量
[root@wj bin]# ll /usr/bin/python*
lrwxrwxrwx. 1 root root 7 12月 15 20:56 /usr/bin/python -> python2
lrwxrwxrwx. 1 root root 9 12月 15 20:56 /usr/bin/python2 -> python2.7
-rwxr-xr-x. 1 root root 68600 9月 9 2021 /usr/bin/python2.7
lrwxrwxrwx 1 root root 33 2月 28 20:22 /usr/bin/python3 -> /usr/local/python3/bin/python3.10
检查是否成功
[root@wj ~]# python -V
Python 2.7.5
[root@wj ~]# python3 -V
Python 3.10.13
注意事项
yum默认是依赖于系统自带的python,需要修改下
[root@wj ~]# vim /usr/bin/yum
#!/usr/bin/python2 #这里修改为实际为2版本的python版本即可
import sys
try:
THE END