码迷,mamicode.com
首页 > 编程语言 > 详细

Centos7_Minimal-1611 版安装python3.5.3

时间:2017-06-11 00:23:37      阅读:274      评论:0      收藏:0      [点我收藏+]

标签:x86_64   copy   get   多个   自己   windows   minimal   uil   左右   

前提

最近在学习python3,看到好多教程都是要求在Windows或者Ubuntu 平台上使用,安装比较方便。由于不在想Winddows上安装也没有Ubutnu系统 ,所以在自己的CentOS7上面装环境

准备工作

CentsOS 虚拟机一台,Minimal 最小化安装版

安装

1、下载Python

下载地址https://www.python.org/downloads/release  这里面包含了多个版本,自己选择下载,我下载的是3.5.3版本

[root@client0 ~]#
wget
https://www.python.org/ftp/python/3.5.3/Python-3.5.3.tgz

2、解压文件并进入目录

[root@client0 ~]#
tar
-zxvf Python-3.5.3.tgz
[root@client0 ~]# cd Python
-3.5.3

3、配置Python环境

#查看有哪里参数
[root@client0 Python-3.5.3]# .
/configure -h #配置安装目录,我这里只配置的安装目录
[root@client0 Python-3.5.3]# .
/configure --prefix=/usr/local/Python3.5.3

4、安装软件

[root@client0 Python-3.5.3]#
make
&& make install

5、安装完成你会发现是没有python3.5的,原来的python命令版本不对的,可以通过下面的命令查看版本

[root@client0 Python-3.5.3]#
python -V

使用ln -s 自己创建一个python3.5的命令

[root@client0 Python-3.5.3]#
ln
-s /usr/local/Python3.5.3/bin/python3.5 /usr/bin/python3.5

如果想让python3.5为默认python使用,可以把原来的python重命名,然后创建一个的python3.5为python,一切OK后运行自己的第一个程序Hello World

[root@client0 Python-3.5.3]# python3.5 
Python 3.5.3 (default, Jun 10 2017, 23:12:52) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print(Hellow World)
Hellow World
>>> 

 

到这里所有的安装已经完成了,剩下的就是在安装过程中自己遇到的一些坑,之所以选用Minimal 最小化安装版是因为这个版本安装的东西的最少,可以发现很多不知道的问题,下面就是遇到的问题总结:

 

安装过程中出现的各种问题

1、-bash: wget: 未找到命令

技术分享

解决方法:

[root@client0 ~]#
yum
install wget -y #或者使用curl
[root@client0 ~]# curl
-O https://www.python.org/ftp/python/3.5.3/Python-3.5.3.tgz

2、配置Python3.5,使用./configure --prefix=/usr/local/Python3.5.3报错如下

checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for python3.5... 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.5.3‘:
configure: error: no acceptable C compiler found in $PATH

  解决办法安装“Development tools”开发工具包,然后再./configure就可以了

[root@client0 ~]#
yum
groupinstall "Development tools" -y

3、make && make install 到最后提示

Ignoring ensurepip failure: pip 9.0.1 requires SSL/TLS

这个时间只需要安装一下openssl 和openssl-devel 就可以了

[root@client0 ~]#
yum
install openssl openssl-devel -y

4、安装完成后使用python3.5进入python 界面发现左右等键不能使用报错如下时

[root@client0 Python-3.5.3]# python3.5 
Python 3.5.3 (default, Jun 10 2017, 23:12:52) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print()^[[D^[[C^[[D^[[C

这个时候是因为我们缺少readline 、readline-devel包,通过下面的命令来确认一下,没有安装的时候全新安装一下就可以了,安装完成需要重启编译python3.5

[root@client0 Python-3.5.3]# rpm -qa | grep readline
readline-6.2-9.el7.x86_64
#发现只有readline 没有readline-devel,使用下面的命令安装一下
[root@client0 Python-3.5.3]# 
 yum install readline-devel -y
#安装完成后还需要重新编译pythone3.5
[root@client0 Python-3.5.3]# 
make && make install 

 

Centos7_Minimal-1611 版安装python3.5.3

标签:x86_64   copy   get   多个   自己   windows   minimal   uil   左右   

原文地址:http://www.cnblogs.com/changelee/p/6980385.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!