linux安装python3.6.7_Linux安装python3.6.7/定时crontab/安装命令

论坛 期权论坛 期权     
选择匿名的用户   2021-5-23 00:26   6584   0

一般情况下都会自带安装了python2,所以不要删除。继续安装你的python3就好,因为某些程序需要依赖目前python2环境。

一.安装依赖环境

# 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

二.下载Python3

从[官网下载](https://www.python.org/downloads/)相应的Python版本,目前最新版本为Python3.6.7,[点击下载](https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tgz)。

也可以通过如下命令下载:

wget https://www.python.org/ftp/python/3.6.7/Python-3.6.7.tgz

三.安装

在Python下载目录依次运行如下命令

[root@cdh1 opt]# tar zxvf Python-3.6.7.tgz

[root@cdh1 opt]# cd Python-3.6.7

创建安装目录

[root@cdh1 Python-3.6.7]# mkdir -p /usr/local/python3

[root@cdh1 Python-3.6.7]# ./configure --prefix=/usr/local/python3

[root@cdh1 Python-3.6.7]# make

[root@cdh1 Python-3.6.7]# make install

make是一个编译命令,如果make的时候出现以下情况

那就是没有找到makefile,可以看下configure的时候有没有报错呀?是不是提示有什么依赖的包没有装,先把依赖的包装了。再configure试试,看有没有makefile。

四.安装依赖包(若不报错,则此步骤不用安装)

安装python的时候出现如下的错误:

Python3.6安装报错 configure: error: no acceptable C compiler found in $PATH**

[root@master ~]#./configure --prefix=/usr/local/python3.6

checking build system type... i686-pc-linux-gnu

checking host system type... i686-pc-linux-gnu

checking for --enable-universalsdk... no

checking for --with-universal-archs... 32-bit

checking MACHDEP... linux

checking for --without-gcc... no

checking for gcc... no

checking for cc... no

checking for cl.exe... no

configure: error: in `/usr/local/src/pythonSoft/Python-3.3.4':

configure: error: no acceptable C compiler found in $PATH

See `config.log' for more details

由于本机缺少gcc编译环境

1.通过yum安装gcc编译环境:yum install -y gcc

2.本机没有安装yum功能,可下载gcc安装包:https://gcc.gnu.org/

[root@cdh1 Python-3.6.7]# yum install -y gcc

然后再make

[root@cdh1 Python-3.6.7]# make

[root@cdh1 Python-3.6.7]# make install

五.建立python3的软链

一般情况下使用第一种方法

第一种方法:直接创建

[root@cdh1 Python-3.6.7]# ln -s /usr/local/python3/bin/python3 /usr/bin/python3

第二种方法:创建新版本的软连接

###修改旧版本

mv /usr/bin/python /usr/bin/python_bak

###创建新的软连接

ln -s /usr/local/python3/bin/python3 /usr/bin/python

六.将(/usr/local/python3/bin)加入PATH 路径

[root@cdh1 Python-3.6.7]# vim ~/.bash_profile

将原:PATH=$PATH:$HOME/bin:

改成:PATH=$PATH:$HOME/bin:/usr/local/python3/bin

\# .bash_profile

\# Get the aliases and functions

if [ -f ~/.bashrc ]; then

. ~/.bashrc

fi

\# User specific environment and startup programs

PATH=$PATH:$HOME/bin:/usr/local/python3/bin

export PATH

按ESC,输入:wq回车退出

七.修改完PATH路径记得执行

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP