mac系统自带python2.7版本,所以在直接使用pip的时候,找不到pip,我们通过重新安装python更新pip的版本,然后用pip安装Scrapy(S大写)。
- brew install python 通过安排python,升级pip–>pip3
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 <package>
They will install into the site-package directory
/usr/local/lib/python3.6/site-packages
See: https://docs.brew.sh/Homebrew-and-Python
2.>>>pip #无效
3.pip因为python的升级也升级了,
>>>pip3 -V
pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)
4.python2的开启方式
bogon:www zhangxiaojing$ python
Python 2.7.10 (default, Jul 15 2017, 17:16:57)
[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.
>>> quit();
5.python3的开启方式
bogon:www zhangxiaojing$ python3
Python 3.6.4 (default, Mar 9 2018, 23:15:03)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> quit();
bogon:www zhangxiaojing$ python -V
Python 2.7.10
bogon:www zhangxiaojing$ python3 -V
Python 3.6.4
6.安装Scrapy
bogon:www zhangxiaojing$ pip3 install Scrapy
Collecting Scrapy
...
Successfully built PyDispatcher Twisted zope.interface pycparser
Installing collected packages: pyasn1, attrs, pyasn1-modules, six, asn1crypto, pycparser, cffi, cryptography, pyOpenSSL, service-identity, w3lib, PyDispatcher, lxml, cssselect, parsel, zope.interface, constantly, incremental, Automat, hyperlink, Twisted, queuelib, Scrapy
Successfully installed Automat-0.6.0 PyDispatcher-2.0.5 Scrapy-1.5.0 Twisted-17.9.0 asn1crypto-0.24.0 attrs-17.4.0 cffi-1.11.5 constantly-15.1.0 cryptography-2.2 cssselect-1.0.3 hyperlink-18.0.0 incremental-17.5.0 lxml-4.2.0 parsel-1.4.0 pyOpenSSL-17.5.0 pyasn1-0.4.2 pyasn1-modules-0.2.1 pycparser-2.18 queuelib-1.5.0 service-identity-17.0.0 six-1.11.0 w3lib-1.19.0 zope.interface-4.4.3
You are using pip version 9.0.1, however version 9.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
7.运行成功,开启项目
bogon:www zhangxiaojing$ 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