关于python:python安装

8次阅读

共计 1606 个字符,预计需要花费 5 分钟才能阅读完成。

一:在 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"。

留神:

  1. 在执行./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
  1. 在执行 make install 时报错:
zipimport.ZipImportError: can't decompress data; zlib not available make

解决办法:

  • 装置 zlib 相干依赖包
yum -y install zlib*
  • 从新执行装置
make && make install
  1. 装置实现之后应用 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
正文完
 0