一:在windows下安装python
1:登录python官网下载安装包
https://www.python.org/downlo...
2:安装python
将下载下来的python安装包正常安装即可,只需要注意:记得勾选 Add Python 3.8 to PATH。这里是让他安装的时候自动帮你添加环境变量,免得还要去自己添加环境变量
安装后,如果你没有勾选Add Python 3.8 to PATH的话需要自己添加环境变量右击计算机->属性->高级系统设置->环境变量->修改系统变量path,添加Python安装地址
3:判断python是否安装成功
在命令行输入python --version出现如下现象说明安装成功
二:在linux下安装python
1:下载python
打开WEB浏览器访问 https://www.python.org/downlo...将适用于 Linux 的源码压缩包下载下来。
2:安装python
tar -zxvf Python-3.6.4.tgz
cd Python-3.6.4
./configure --with-ssl
make && make install
如果显示没有安装成功可能是没有设置环境变量
export PATH="$PATH:/usr/local/bin/python" ,按下"Enter"。
注意:
- 在执行./configure时可能会报以下错误:
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for python3.6... no
checking for python3... no
checking for python... python
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
checking MACHDEP... linux
checking for --without-gcc... no
checking for --with-icc... no
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/root/Python-3.6.4':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
解决办法:
- 先安装GCC软件套件
yum install gcc
- 重新编译
./configure --with-ssl
- 在执行make install时报错:
zipimport.ZipImportError: can't decompress data; zlib not available make
解决办法:
- 安装zlib相关依赖包
yum -y install zlib*
- 重新执行安装
make && make install
- 安装完成之后使用pip3去安装python3插件报错:
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
解决办法:
- 查看openssl安装包
rpm -aq|grep openssl
查看是否缺少openssl-devel包,
- 安装openssl-devel
yum install openssl-devel -y
- 对python3进行重新编译
cd Python-3.6.4
./configure --with-ssl
make
sudo make install
- pip3升级:
pip3 install --upgrade pip
3:判断python是否安装成功
# python3 -V
Python 3.8.6