liunx下如何安装Python3

作者: even_366 | 来源:发表于2017-10-27 13:21 被阅读18次

1. 下载
官网下载需要执行的安装文件。

wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0a1.tar.xz

2.解压安装包
利用tar命令解压文件到当前目录。

tar xvf Python-3.7.0a1.tar.xz

3.安装
安装Python3.7安装到/usr/local目录中,执行configure。

./configure --prefix=/usr/local

注意执行出现:
configure: error: no acceptable C compiler found in $PATH
因为是centos linux,默认可以采用yum方式安装,则采用如下命令安装gcc编译器即可:
yum -y install gcc
前提是linux可以在线更新。

执行安装命令

make&& make install

4.测试
在线测试python3是否安装成功

python3 

显示如下

Python 3.7.0a1 (default, Oct 27 2017, 12:28:35)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

5.Hello world
创建一个hello.py文件

#!/usr/bin/python3
print("hello world!");

执行hello.py文件

python hello.py
#打印如下
hello world!

微信号:even366

相关文章

网友评论

    本文标题:liunx下如何安装Python3

    本文链接:https://www.haomeiwen.com/subject/xtbrpxtx.html