zoukankan      html  css  js  c++  java
  • 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













  • 相关阅读:
    BZOJ3813 奇数国
    BZOJ2735 世博会
    BZOJ2081 [Poi2010]Beads
    BZOJ3276 磁力
    BZOJ2054 疯狂的馒头
    BZOJ2610 [Poi2003]Monkeys
    BZOJ2428 [HAOI2006]均分数据
    BZOJ2120 数颜色
    BZOJ2527 [Poi2011]Meteors
    补比赛——牛客OI周赛9-普及组
  • 原文地址:https://www.cnblogs.com/regit/p/8186288.html
Copyright © 2011-2022 走看看