Centos7下安装Python3.7

Centos7下安装Python3.7

首先安装依赖包,centos里面是-devel,如果在ubuntu下安装则要改成-dev,依赖包缺一不可,笔者曾安装python3未成功就是因为没有安装libffi-devel

yum -y groupinstall "Development tools"

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 libffi-devel


然后获取python3.7的安装包

wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0a1.tar.xz


cd ~/Download  这个地方你自己的下载目录

tar -xvJf  Python-3.7.0a1.tar.xz


配置python3的安装目录并安装

cd Python-3.7.0a1

./configure --prefix=/usr/local/python3

make

make install


创建软链接

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

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


也可用

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

ln -s /usr/local/bin/python3/bin/pip3 /usr/bin/pip

更原生一点


设置环境(退出就无效了,永久的办法用 4 .5.)

可以将/opt/apps/python3/bin加入系统环境变量,

#echo 'export PATH=$PATH:/opt/apps/python3/bin' >> ~/.bash_profile


4. 永久添加环境变量(影响当前用户)

#vim ~/.bashrc

export PATH="/opt/STM/STLinux-2.3/devkit/sh4/bin:$PATH"


5.永久添加环境变量(影响所有用户)

#vim /etc/profile

在文档最后,添加:

export PATH="/opt/STM/STLinux-2.3/devkit/sh4/bin:$PATH"

保存,退出,然后运行:

#source /etc/profile


/opt/apps/python3/bin 为 安装路径

而我们简单的建立软链接比较方便

#ln -s /opt/apps/python3/bin/python3 /usr/bin



最后在命令行中输入python3,能够进入python3终端即成功安装 


4. 永久添加环境变量(影响当前用户)

#vim ~/.bashrc

export PATH="/opt/STM/STLinux-2.3/devkit/sh4/bin:$PATH"


5.永久添加环境变量(影响所有用户)

#vim /etc/profile

在文档最后,添加:

export PATH="/opt/STM/STLinux-2.3/devkit/sh4/bin:$PATH"

保存,退出,然后运行:

#source /etc/profile

不报错则成功。

你可能感兴趣的:(Centos7下安装Python3.7)