centos6装python3,并安装requests, lxml和beautifulsoup模块

 

 

 一.  安装python3并设为默认版本,与python2共存

 

1、下载Python3.4安装包

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

2、解压、编译、安装

     yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make

  tar zxvf Python-3.4.4.tgz
  cd Python-3.4.4
  ./configure --prefix=/usr/local/python3
  make
  make install

3、创建Python3.4的链接,并且设置python3为默认版本(CentOS6.7默认安装的是Python2)

     cd /usr/bin/

     ln -s /usr/local/python3/bin/python3.4 python   #如果不想为默认版本,把python改为python3

 

4.  因为执行yum需要python2版本,所以我们还要修改yum的配置

     vi /usr/bin/yum 把#! /usr/bin/python修改为#! /usr/bin/python2

 

 

 

二.  安装模块

 

1. 安装beautifulsoup

   tar xvzf beautifulsoup4-4.5.1.tar.gz
   cd beautifulsoup4-4.5.1 
   python setup.py install

 

2. 安装requests

   wget https://bootstrap.pypa.io/get-pip.py
   python get-pip.py 
   pip install requests
 
3. 安装lxml,依赖有libxml2-devel,libxslt-devel
    yum install libxml2-devel libxslt-devel -y
    pip install lxml

 














转载于:https://www.cnblogs.com/regit/p/8186288.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值