当前位置: 移动技术网 > IT编程>脚本编程>Python > 【Python 开发】第二篇 :Python安装

【Python 开发】第二篇 :Python安装

2018年09月19日  | 移动技术网IT编程  | 我要评论

赵县汽车站,皇冠娱乐从搜博网开始,特勤队2新手卡

一、python3.x安装

1)由于centos7原本就安装了python2,而且这个python2不能被删除,因为有很多系统命令,比如yum都要用到。

官网:

[root@host130 ~]# python
python 2.7.5 (default, nov  6 2016, 00:28:07) 
[gcc 4.8.5 20150623 (red hat 4.8.5-11)] on linux2
type "help", "copyright", "credits" or "license" for more information.
>>> exit()
[root@host130 ~]# which python
/usr/bin/python
[root@host130 ~]# 

二、源码安装python3.7  

2)通过源码安装python3.x,我选择是安装python3.7
2.1 下载依赖包
[root@host130 ~]# yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel 

2.2 下载不同版本的python3,我下载的是python3.7
[root@host130 src]# pwd
/usr/local/src
[root@host130 src]#
[root@host130 src]# wget https://www.python.org/ftp/python/3.7.0/python-3.7.0rc1.tgz
[root@host130 src]# tar -zxvf python-3.7.0rc1.tgz
[root@host130 src]# cd python-3.7.0rc1/
[root@host130 python-3.7.0rc1]# ls
aclocal.m4    configure.ac  install-sh  mac              objects  programs       setup.py
config.guess  doc           lib         makefile.pre.in  parser   pyconfig.h.in  tools
config.sub    grammar       license     misc             pc       python
configure     include       m4          modules          pcbuild  readme.rst
[root@host130 python-3.7.0rc1]# ./config
config.guess  config.sub    configure     
[root@host130 python-3.7.0rc1]# ./configure --prefix=/usr/local/python3
[root@host130 python-3.7.0rc1]# make && make install
[root@host130 python-3.7.0rc1]# ln -s /usr/local/python3/bin/python3 /usr/bin/python3
[root@host130 python-3.7.0rc1]# ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
[root@host130 python-3.7.0rc1]# python3
python 3.7.0rc1 (default, sep 18 2018, 18:22:18) 
[gcc 4.8.5 20150623 (red hat 4.8.5-11)] on linux
type "help", "copyright", "credits" or "license" for more information.
>>> exit
use exit() or ctrl-d (i.e. eof) to exit
>>> 
参考博客:https://www.cnblogs.com/dangkai/p/9394363.html

三、编译时报错处理

o module named '_ctypes'    参考博客:https://blog.csdn.net/qq_36416904/article/details/79316972

的解决办法: 原因:3.7版本需要一个新的包libffi-devel,安装此包之后再次进行编译安装即可。 [root@host130 python-3.7.0rc1]# yum -y install libffi-devel [root@host130 python-3.7.0rc1]# make && make install 安装成功: [root@host130 python-3.7.0rc1]# ln -s /usr/local/python3/bin/python3 /usr/bin/python3 [root@host130 python-3.7.0rc1]# ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3 [root@host130 python-3.7.0rc1]# python3 python 3.7.0rc1 (default, sep 18 2018, 18:22:18) [gcc 4.8.5 20150623 (red hat 4.8.5-11)] on linux type "help", "copyright", "credits" or "license" for more information. >>> exit use exit() or ctrl-d (i.e. eof) to exit >>>

 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网