关于python:python安装

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

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理