mac安装scrapy并创建项目的实例讲解

yipeiwu_com5年前Python基础

最近刚好在学习python+scrapy的爬虫技术,因为mac是自带python2.7的,所以安装3.5版本有两种方法,一种是升级,一种是额外安装3.5版本。

升级就不用说了,讲讲额外安装的版本吧~~~

因为python是有自带版本的,最开始安装的时候都会有一种“ 会不会冲突 ”的感觉。

其实安装3.5版本也就是在官网上直接下载之后安装,和普通的mac软件安装方式是一样的~~

https://www.python.org/downloads/release/python-353/

安装完成之后,不会覆盖原来的python,会在 /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5文件中

在终端直接输入 python 会执行python2.7版本

python 
 
Python 2.7.12 (default, Jun 29 2016, 14:05:02) 
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)] on darwin 
Type "help", "copyright", "credits" or "license" for more information. 
>>> 

在终端直接输入 python3 则会执行python3.5版本

python3 
 
Python 3.5.3 (v3.5.3:1880cb95a742, Jan 16 2017, 08:49:46) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin 
Type "help", "copyright", "credits" or "license" for more information. 
>>> 

接下来就可以开始安装scrapy了

python3.5中会自带 pip,所以不需要额外安装了,可以直接在终端输入 pip3 --version查看版本和路径

pip3 --version 
 
pip 9.0.1 from /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (python 3.5) 

使用 pip3 安装scrapy

pip3 install Scrapy 

这里的Scrapy一定要首字母大写,不然会在安装的过程中报错~~

Collecting scrapy
 Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x103aa2c88>: Failed to establish a new connection: [Errno 61] Connection refused',)': /simple/scrapy/
 Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x103aa29e8>: Failed to establish a new connection: [Errno 61] Connection refused',)': /simple/scrapy/
 Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x103aa2630>: Failed to establish a new connection: [Errno 61] Connection refused',)': /simple/scrapy/
 Retrying (Retry(total=1, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x103aa2f28>: Failed to establish a new connection: [Errno 61] Connection refused',)': /simple/scrapy/
 Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x103aa2be0>: Failed to establish a new connection: [Errno 61] Connection refused',)': /simple/scrapy/
 Could not find a version that satisfies the requirement scrapy (from versions: )
No matching distribution found for scrapy

安装成功之后,可以直接在终端上输入 scrapy 查看版本号及使用

Scrapy 1.4.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

在pycharm中是没有直接创建scrapy项目的,可以使用 scrapy 命令手动新建项目

scrapy startproject ArticleSpider(ArticleSpider为项目名称) 

以上这篇mac安装scrapy并创建项目的实例讲解就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

浅谈Python NLP入门教程

浅谈Python NLP入门教程

正文 本文简要介绍Python自然语言处理(NLP),使用Python的NLTK库。NLTK是Python的自然语言处理工具包,在NLP领域中,最常使用的一个Python库。 什么是NL...

Django的models模型的具体使用

model的常用字段 V=models.CharField(max_length=None[, **options])    #varchar V=models.EmailFiel...

Python Queue模块详细介绍及实例

Python Queue模块 Python中,队列是线程间最常用的交换数据的形式。Queue模块是提供队列操作的模块,虽然简单易用,但是不小心的话,还是会出现一些意外。 创建一个“队列...

python3.6下Numpy库下载与安装图文教程

python3.6下Numpy库下载与安装图文教程

今天在做Plotly的散点图时,需要Numpy 这个库的使用。 没有安装Numpy这个库的时候,报错一般是下图这样:ModuleNotFoundError: No module name...

浅谈python中的__init__、__new__和__call__方法

前言 本文主要给大家介绍关于python中__init__、__new__和__call__方法的相关内容,分享出来供大家参考学习,下面话不多说,来一起看看详细的介绍: 任何事物都有一个...