您好,登錄后才能下訂單哦!
最近剛好在學習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并創建項目的實例講解就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持億速云。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。