mac 安装Scrapy

mac系统自带python2.7版本,所以在直接使用pip的时候,找不到pip,我们通过重新安装python更新pip的版本,然后用pip安装Scrapy

1.brew install python 通过安排python,升级pip–>pip3

ApplematoAir:~ apple$ brew install python
Updating Homebrew...
...
==> python
Python has been installed as
  /usr/local/bin/python3
 
Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have been installed into
  /usr/local/opt/python/libexec/bin
 
If you need Homebrew's Python 2.7 run
  brew install python@2
 
Pip, setuptools, and wheel have been installed. To update them run
  pip3 install --upgrade pip setuptools wheel
 
You can install Python packages with
  pip3 install 
They will install into the site-package directory
  /usr/local/lib/python3.7/site-packages
 
See: https://docs.brew.sh/Homebrew-and-Python

2.pip因为python的升级变成pip3了

ApplematoAir:~ apple$ pip3 -V
pip 18.0 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)

3.python2打开方式

python
Python 2.7.10 (default, Oct  6 2017, 22:29:07) 
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

4.python3打开方式

ApplematoAir:~ apple$ python3
Python 3.7.0 (default, Aug 22 2018, 15:22:33) 
[Clang 9.1.0 (clang-902.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

5.安装Scrapy

pip3 install Scrapy
Collecting Scrapy
  Downloading https://files.pythonhosted.org/packages/5d/12/a6197eaf97385e96fd8ec56627749a6229a9b3178ad73866a0b1fb377379/Scrapy-1.5.1-py2.py3-none-any.whl (249kB)
...
Successfully built Twisted PyDispatcher zope.interface pycparser
Installing collected packages: pyasn1, pyasn1-modules, attrs, asn1crypto, pycparser, cffi, idna, six, cryptography, pyOpenSSL, service-identity, lxml, zope.interface, constantly, incremental, Automat, hyperlink, PyHamcrest, Twisted, PyDispatcher, queuelib, cssselect, w3lib, parsel, Scrapy
Successfully installed Automat-0.7.0 PyDispatcher-2.0.5 PyHamcrest-1.9.0 Scrapy-1.5.1 Twisted-18.7.0 asn1crypto-0.24.0 attrs-18.1.0 cffi-1.11.5 constantly-15.1.0 cryptography-2.3.1 cssselect-1.0.3 hyperlink-18.0.0 idna-2.7 incremental-17.5.0 lxml-4.2.4 parsel-1.5.0 pyOpenSSL-18.0.0 pyasn1-0.4.4 pyasn1-modules-0.2.2 pycparser-2.18 queuelib-1.5.0 service-identity-17.0.0 six-1.11.0 w3lib-1.19.0 zope.interface-4.5.0

6.测试软件是否安装成功

scrapy
Scrapy 1.5.1 - no active project
 
Usage:
  scrapy [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 -h" to see more info about a command
mac 安装Scrapy

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

18 − 17 =

滚动到顶部
沪ICP备18028346号