【Linux】CentOS7安装Python3
来源:互联网 发布:长城宽带是什么网络 编辑:程序博客网 时间:2024/06/05 23:06
一、完善Linux环境,安装需要的工具
CentOS7默认已经安装了Python2.7,所以如果还需要安装Python3的话需要安装需要的工具以及相关包(这里统一采用Yum命令安装),当然以及安装过的可以跳过
gcc
yum install gcc
zlib-devel
yum install zlib-devel
openssl-devel
yum install openssl-devel
bzip2-devel
yum install bzip2-devel
ncurses-devel
yum install ncurses-devel
sqlite-devel
yum install sqlite-devel
readline-devel
yum install readline-devel
tk-devel
yum install tk-devel
二、下载安装Python3
1.下载Python3安装包
wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tgz
2.解压安装包
tar -xzvf Python-3.6.2.tgz
3.配置安装
cd Python-3.6.2
./configure --prefix=/usr/local/python3 --enable-shared --with-ssl
4.安装
make && make install
5.清除编译的可执行文件和配置文件以及所有生成的文件
make clean
make distclean
三、系统配置
1.新建python3软连接
cd /usr/bin
[root@localhost bin]# ls -ltr python*-rwxr-xr-x. 1 root root 7136 Nov 19 2015 python2.7lrwxrwxrwx. 1 root root 9 Sep 4 11:25 python2 -> python2.7lrwxrwxrwx. 1 root root 7 Sep 4 11:25 python -> python2[root@localhost bin]# ln -s /usr/local/python3/bin/python3.6 /usr/bin/python3[root@localhost bin]# ls -ltr python*-rwxr-xr-x. 1 root root 7136 Nov 19 2015 python2.7lrwxrwxrwx. 1 root root 9 Sep 4 11:25 python2 -> python2.7lrwxrwxrwx. 1 root root 7 Sep 4 11:25 python -> python2lrwxrwxrwx. 1 root root 32 Sep 5 11:24 python3 -> /usr/local/python3/bin/python3.6然后就可以直接输入python3来启动python3了四、错误解决
1、启动python3时的错误
[root@localhost bin]# python3python3: error while loading shared libraries: libpython3.6m.so.1.0: cannot open shared object file: No such file or directory解决办法:[root@localhost bin]# cd /etc/ld.so.conf.d/[root@localhost ld.so.conf.d]# dirdyninst-x86_64.conf kernel-3.10.0-327.el7.x86_64.confmariadb-x86_64.conf[root@localhost ld.so.conf.d]# vim python3.conf#在python3.conf文件里面输入 /usr/local/python3/lib 然后保存并退出[root@localhost ld.so.conf.d]# ldconfig[root@localhost ld.so.conf.d]# python3Python 3.6.2 (default, Sep 5 2017, 10:47:56)[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linuxType "help", "copyright", "credits" or "license" for more information.>>>
阅读全文
0 0
- 【Linux】CentOS7安装Python3
- Linux centos7 安装python3.6.3
- Linux CentOS7自定义安装Python和Python3
- LINUX CENTOS7下安装PYTHON3.5.4
- Linux Centos7-安装python3.5.2 pip setuptools
- CentOS7安装Python3
- centos7下安装python3
- centos7安装python3.5
- Centos7安装Python3.5
- centos7安装Python3.5
- CentOS7安装Python3.6.0
- CentOS7安装Python3
- CentOS7安装python3.6.1
- CentOS7 安装Python3
- CentOS7安装Python3.6
- Centos7 Python3.5.2安装
- CentOS7安装Python3
- centos7安装python3
- CRC-16 (Modbus)校验码
- 数据库复习总结(未写完...)
- e.target与e.currentTarget的区别
- /usr/bin/ld: cannot find -lxxx 问题解决
- Microsoft Edge真奇怪
- 【Linux】CentOS7安装Python3
- 阿里业务研发经典案例:另类解法,分布式一致性
- C#实现item自定义颜色的ListBox,显示日志
- 虚拟机配置静态ip
- MySQL存储AES_ENCRYPT加密字段
- idea配置MAVEN
- 接口和简单工厂设计模式
- 电路基础学习笔记4:复杂直流电路分析2
- 闭包