1. 程式人生 > >Centos7下成功安裝python3和scrapy爬蟲

Centos7下成功安裝python3和scrapy爬蟲

1、安裝python3(保留python2)

(1)原始碼編譯前準備

[root@hadron ~]# yum -y groupinstall "Development tools"
[root@hadron ~]# 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

如果上面命名報錯,按照提示加上--skip-broken

[root@hadron
~]# 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 --skip-broken

(2)下載Python-3.5原始碼

[root@hadron ~]#  wget https://www.python.org/ftp/python/3.5.5/Python-3.5.5.tgz

然後解壓縮,進入根目錄

[root@hadron ~]# tar -zxvf Python-3.5.5.tgz 
[root@hadron ~]# cd Python-3.5.5/

(3)編譯安裝

[root@hadron ~]#  ./configure --prefix=/usr/local/python3
[root@hadron ~]#  make && make install

(4)建立軟連結

[root@hadron ~]#  ln -s /usr/local/python3/bin/python3 /usr/bin/python3
[root@hadron ~]#  ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3

(5)驗證

[root@hadron
~]# python Python 2.7.5 (default, Nov 6 2016, 00:28:07) [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> quit() [root@hadron ~]# python3 Python 3.5.5 (default, Feb 27 2018, 09:28:49) [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> quit() [root@hadron ~]#

2、安裝scrapy爬蟲

(1)安裝scrapy

[[email protected] ~]# pip3 install scrapy
Collecting scrapy
  Downloading Scrapy-1.5.0-py2.py3-none-any.whl (251kB)
    100% |████████████████████████████████| 256kB 1.1MB/s 
Requirement already satisfied: lxml in /usr/local/python3/lib/python3.5/site-packages (from scrapy)
Collecting PyDispatcher>=2.0.5 (from scrapy)
  Downloading PyDispatcher-2.0.5.tar.gz
....
....
Collecting pycparser (from cffi>=1.7; platform_python_implementation != "PyPy"->cryptography>=2.1.4->pyOpenSSL->scrapy)
  Downloading pycparser-2.18.tar.gz (245kB)
    100% |████████████████████████████████| 256kB 339kB/s 
Installing collected packages: PyDispatcher, zope.interface, constantly, incremental, six, attrs, Automat, hyperlink, Twisted, cssselect, w3lib, parsel, asn1crypto, pycparser, cffi, cryptography, pyOpenSSL, pyasn1, pyasn1-modules, service-identity, queuelib, scrapy
  Running setup.py install for PyDispatcher ... done
  Running setup.py install for Twisted ... done
  Running setup.py install for pycparser ... done
Successfully installed Automat-0.6.0 PyDispatcher-2.0.5 Twisted-17.9.0 asn1crypto-0.24.0 attrs-17.4.0 cffi-1.11.4 constantly-15.1.0 cryptography-2.1.4 cssselect-1.0.3 hyperlink-18.0.0 incremental-17.5.0 parsel-1.4.0 pyOpenSSL-17.5.0 pyasn1-0.4.2 pyasn1-modules-0.2.1 pycparser-2.18 queuelib-1.4.2 scrapy-1.5.0 service-identity-17.0.0 six-1.11.0 w3lib-1.19.0 zope.interface-4.4.3
[[email protected] ~]#

(2)在python3 shell中驗證scrapy

[root@hadron ~]# python3
Python 3.5.5 (default, Feb 27 2018, 09:28:49) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import scrapy
>>> scrapy.version_info
(1, 5, 0)
>>>

(3)建立軟scrapy連結

[root@hadron ~]# ln -s /usr/local/python3/bin/scrapy  /usr/bin/scrapy

(4)在shell中驗證scrapy


[[email protected] ~]# scrapy
Scrapy 1.5.0 - no active project

Usage:
  scrapy <command> [options] [args]

Available commands:
  bench         Run quick benchmark test
  fetch         Fetch a URL using the Scrapy downloader
  genspider     Generate new spider using pre-defined templates
  runspider     Run a self-contained spider (without creating a project)
  settings      Get settings values
  shell         Interactive scraping console
  startproject  Create new project
  version       Print Scrapy version
  view          Open URL in browser, as seen by Scrapy

  [ more ]      More commands available when run from project directory

Use "scrapy <command> -h" to see more info about a command
[[email protected] ~]# 
[[email protected] ~]# scrapy -v
Scrapy 1.5.0 - no active project

Usage:
  scrapy <command> [options] [args]

Available commands:
  bench         Run quick benchmark test
  fetch         Fetch a URL using the Scrapy downloader
  genspider     Generate new spider using pre-defined templates
  runspider     Run a self-contained spider (without creating a project)
  settings      Get settings values
  shell         Interactive scraping console
  startproject  Create new project
  version       Print Scrapy version
  view          Open URL in browser, as seen by Scrapy

  [ more ]      More commands available when run from project directory

Use "scrapy <command> -h" to see more info about a command
[[email protected] ~]#

相關推薦

Centos7成功安裝python3scrapy爬蟲

1、安裝python3(保留python2) (1)原始碼編譯前準備 [root@hadron ~]# yum -y groupinstall "Development tools" [root@hadron ~]# yum -y install

centos7編譯安裝lnmpnginx代理實驗

ket orm pass glib href status log nal listen 1、先安裝mysql cd /usr/local/src wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.35-linux

詳解Centos7 編譯安裝Nginxyum搭建Nginx兩種方法

Nginx 在併發與負載能力方面確實優於 apache,大多數網站都採用基於Nginx 來搭建網站。 下面就來介紹Nginx的搭建 一 原始碼安裝nginx 首先先來安裝Nginx,但是本地的yum倉庫中只有apache,並沒有Nginx,這就需要手動安裝了。 Nginx 的下載官網是這個http

centos7.2上安裝python3pip19.0.3

lin net 超鏈接 err edi com ldd grep centos 安裝libressl 下載地址: https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-2.7.4.tar.gz 或者 :https:/

CentOS7安裝Python3Python2並存

python3 python yum (一)簡述剛安裝的centos7.4版本默認是安裝Python2.7,由於一些命令需要使用的原因,比如yum等,使用的是2.7.5版本的,由於現在很多庫包括django都是使用Python3,因此,有這樣的需求:yum使用python2.7版本,django和其他

Python3.5成功安裝Scrapy框架

一、本地環境win10+64位作業系統二、安裝步驟1、升級pip1.1 開啟命令提示符視窗,輸入命令:python -m pip install --upgrade pip2、安裝Visual Studio 2015專業版,自行解決。本人從事.NET開發,本機一直都有安裝,未

【轉載】64位Win7成功安裝64位的Oracle、32位的InstantClientPLSQL Developer

註銷 五步 ldb 需要 windows inf 目錄 登錄 class 感謝原作者,原文鏈接:https://wenku.baidu.com/view/433d0b544a7302768f993926.html 經實際安裝操作,通過以下步驟能夠成功地把Oracle安裝到

windows同時安裝python2python3

htm 正常 post 麻煩 ima 分享圖片 pos 一位 mage 之前學習的時候使用2.7比較多。 想練習3.7的時候,兩個版本兼容的問題,苦惱了幾天。 查了一下資料,發現了一個很好的方法。記錄一下,也做一個分享。 本篇內容主要講一下,在同一臺電腦上如何同時安裝P

Centos7 squid安裝 以及 傳統代理透明代理的部署

文件大小 cmd 過程 running useradd ply chm nologin 命令 Centos7 下 squid代理服務安裝 代理服務的工作機制 作為應用層的代理服務軟件, Squid主要提供緩存加速和應用層過濾控制的功能。 當客戶機通過代理來請求Web頁面時,

centos7mongoDB安裝配置

profile sta 後臺 守護 .cn 保存 配置 oca 命名 2018-10-31更新 yum –y install mongodb-org 找不到這個包,清華源: https://mirrors.tuna.tsinghua.edu.cn/help/mongodb/

Centos安裝python3 pip3

有大半年沒摸linux了,遇到2個問題,先記錄一下 1.掛載cdrom VM -設定-CD / DVD/ ios映象 選centos安裝包, mount -t auto /dev/cdrom /mnt/cdrom ,然後進入/mnt/cdrom/package 可以安裝各種rpm包 rp

centos7mongodb安裝配置 (轉載)

1、下載安裝包 curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.2.12.tgz 2、解壓 tar -zxvf mongodb-linux-x86_64-3.2.12.tgz

Windows 7同時安裝python2python3

今天在windows7 已經安裝了Python3.7.0的情況下,又下載安裝了Python2.7.11,然而,在安裝pip2工具時,遇到種種問題,網路上的教程解決方案紛繁雜亂,實在是心累,現在開始解除安裝py2和py3,重新安裝py2和py3和編輯器PyCharm,安裝過程全

Centos7安裝python3pip3

一、 安裝python3 CentOS7中預設安裝的python是2.75的,如果想要使用python3,那麼還需要安裝python3 二、修復yum,並升級 1.修改檔案 /usr/libexec/urlgrabber-ext-down,指定python版本

centoOS安裝python3 pip: command not found

在更新python3的時候會自動安裝pip3,但是安裝完成後,pip -V發現出錯:command not found,找了好久,發現在建立軟連線的時候路徑寫錯了。 總結一下安裝python3和發現pip:command not found 之後的思路。

Linux系統centos7安裝Python3Postman

Python3的安裝: 1.開啟WEB瀏覽器訪問 https://www.python.org/downloads/source/ 2.選擇適用於 Unix/Linux 的原始碼壓縮包。 3.下載及解壓壓縮包 Python-3.x.x.tgz,3.x.x

windows10+python3.5同時安裝caffetensorflow

這幾天需要安裝caffe,但是大部分教程都沒有說怎麼在已經有tensorflow的同時安裝caffe。在這裡記錄一下,主要寫一下整個安裝過程中的大致流程,忽略詳細步驟。 首先需要安裝anaconda,這裡安裝anaconda的主要原因是,它能夠管理環境,也就是

centos7.5編譯安裝python3.7.0

安裝編譯工具和依賴庫 yum groupinstall "Development Tools" yum -y install wget openssl-devel bzip2-devel expat-devel ncurses-devel gdbm-devel readl

window python3 安裝pipscrapy,lxml 過程出錯解決

如果需要轉載請私信,並說明出處連結,謝謝合作 自己爬過的坑。。。。。 我的環境:win7 python :3.5 一.先在cmd下 進入Python的安裝目錄。 例:C:\Users\asus>cd /d D:\Python\Python

環境準備—之—linux安裝python3pip3

check 技術分享 localhost class 準備 org col edit idl 轉自 上海悠悠 https://www.cnblogs.com/yoyoketang/p/10195102.html 前言 centos7 自帶有 python,但是卻是 py