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

2018-09-19 02:52:07来源:博客园 阅读 ()

新老客户大回馈,云服务器低至5折

一、python3.x安装

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

官网:https://www.python.org/

[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 >>>

 

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:机器学习【算法】:KNN近邻

下一篇:Java基础之进制转换