python-安裝Scrapy

一般mac的電腦都自帶python 但是版本較低 “python2.7”的,所以我們需要去官網(wǎng)下載新的python版本https://www.python.org/downloads/安裝新的版本一般是升級或者安裝新的版本。

在終端輸入 python
$python 打印的系統(tǒng)自帶的版本也就是 2.7版本的
如:

bogon:~ xxx$ python
Python 2.7.15rc1 (v2.7.15rc1:bad9a580ca, Apr 14 2018, 20:05:13) ….

輸入python3就可查看我門新安裝的python有沒有成功
如:

bogon:~ xxx$ python3
Python 3.6.1 (v3.6.1:69c0db5050, Mar 21 2017, 01:21:04) 

如果直接輸入 python3/ python會進入編輯狀態(tài)
只需要輸入quit() 或者 exit() 就可以退出了
如:

[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>> quit()

在python3中自帶有pip3:(這里借取的網(wǎng)上的觀點)
1.只是當一臺電腦同時有多個版本的Python的時候,用pip3就可以自動區(qū)分用Python3來安裝庫。是為了避免和Python2發(fā)生沖突的。
2.如果你的電腦只安裝了Python3,那么不管用pip還是pip3都一樣的。
3.安裝了python3之后,會有pip3
4.使用pip install XXX :
5.新安裝的庫會放在這個目錄下面:python2.7/site-packages;
6.使用pip3 install XXX :
7.新安裝的庫會放在這個目錄下面:python3.6/site-packages;
8.如果使用python3執(zhí)行程序,那么就不能import python2.7/site-packages中的庫。

直接使用 pip3 可以查看pip3的使用方法

bogon:~ xxx$ pip3

Usage:   
 pip <command> [options]

Commands:
install                     Install packages.
download                    Download packages.
uninstall                   Uninstall packages.
 freeze                      Output installed packages in requirements >format.
 list                        List installed packages.
 show                        Show information about installed packages.
 check                       Verify installed packages have compatible >dependencies.
 search                      Search PyPI for packages.
 wheel                       Build wheels from your requirements.
 hash                        Compute hashes of package archives.
 completion                  A helper command used for command >completion.
 help                        Show help for commands.

查看當前pip3版本:

$ pip3 --version
1.
安裝  Scrapy
$ pip3 install Scrapy

2.
cd到你的指定目錄下
$ cd xxx

3.
創(chuàng)建一個scrapy項目
$ scrapy startproject scrapy_process  //scrapy_process文件名

介紹:
進入到新scrapy_process文件夾下會有幾個文件:
1.scrapy.cfg :配置文件
1.__init__.py :
2.items.py :項目中的itme文件
3.middlewares.py :
4.pipelines.py :項目中的pipelines
5.settings.py : 項目中的設置文件
6.spiders : 放spides(爬蟲)代碼的目錄
7.__pycache__ :


最后編輯于
?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

友情鏈接更多精彩內(nèi)容