python-安裝Scrapy

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

在終端輸入 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有沒(méi)有成功
如:

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

如果直接輸入 python3/ python會(huì)進(jìn)入編輯狀態(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)上的觀點(diǎn))
1.只是當(dāng)一臺(tái)電腦同時(shí)有多個(gè)版本的Python的時(shí)候,用pip3就可以自動(dòng)區(qū)分用Python3來(lái)安裝庫(kù)。是為了避免和Python2發(fā)生沖突的。
2.如果你的電腦只安裝了Python3,那么不管用pip還是pip3都一樣的。
3.安裝了python3之后,會(huì)有pip3
4.使用pip install XXX :
5.新安裝的庫(kù)會(huì)放在這個(gè)目錄下面:python2.7/site-packages;
6.使用pip3 install XXX :
7.新安裝的庫(kù)會(huì)放在這個(gè)目錄下面:python3.6/site-packages;
8.如果使用python3執(zhí)行程序,那么就不能import python2.7/site-packages中的庫(kù)。

直接使用 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.

查看當(dāng)前pip3版本:

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

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

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

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


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

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