Linux:Python3.5安装和配置

一、安装前系统设置

1.防火墙设置

centos7.0默认防火墙为firewalld
停止firewall
systemctl stop firewalld.service
禁止firewall开机启动
systemctl disable firewalld.service
查看默认防火墙状态:
firewall-cmd --state

2.修改selinux

setenforce 0
vi /etc/selinux/config
将SELINUX=enforcing改为:SELINUX=disabled

二、安装Python3

CentOS7默认安装了python2.7,当需要使用python3的时候,可以手动下载Python源码后编译安装。

1.安装python3.5可能使用的依赖

yum -y install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel

2.下载python

cd /opt/
scp 10.32.35.100:/data/share/Python-3.5.0.tgz /opt/

3.解压下载好的压缩包

tar -zxvf Python-3.5.0.tgz

4.配置编译

mkdir /usr/local/python3
cd Python-3.5.0
./configure --prefix=/usr/local/python3
make
make install

5.备份旧版本python,链接新版本python

cd /usr/bin/
mv python python.bak
ln -s /usr/local/python3/bin/python3 /usr/bin/python
python -V

6.修改yum配置文件

vi /usr/bin/yum
将第一行指定的python版本改为python2.7(#!/usr/bin/python 改为 #!/usr/bin/python2.7)

三、安装BeautifulSoup4

scp 10.32.35.100:/data/share/beautifulsoup4-4.6.0.tar.gz /opt/
tar -zxvf beautifulsoup4-4.6.0.tar.gz
cd beautifulsoup4-4.6.0
python setup.py install
posted @ 2020-03-01 00:02  Tony小哥  阅读(700)  评论(0编辑  收藏  举报