--- title: Python爬蟲-安裝環境教學 --- # python 爬蟲 環境設定 ## 前言 哈囉大家好,我是小龍,是~~這學期~~上學期網研社 python 爬蟲的講師,這篇教學是教大家怎麼安裝 python (程式語言) 和 jupyter(類似IDE),我使用的是mac系統,不過我也會附上windows的教學。 如果有人學過python或是有一些瞭解,這堂課會使用**python3.6、pip、jupyter、requests、BeautifulSoup**,沒有聽過這些名詞也沒關係,我會循序漸進的帶領大家學習。 <img src="https://i.imgur.com/wOkT3If.gif" style="width:40%;margin: 0 30%;"> 每堂課的code都會公開、放到 [github](https://github.com/teacher144123/PythonCrawler) 上面,方便大家回家複習。 課後對python有問題也歡迎私訊我。[Facebook](https://www.facebook.com/SmallDragonChen) ## 安裝Python 2.x.x 和 3.x.x 是Python的兩個大版本(沒有Python1,放心),但是差別不小,大多數開發者預設使用Python3,有特別的目的才會考慮Python2 **有興趣可以[看看我有關py2和py3的文章](https://www.smalldragon.tw/python37-0-intro/)** 現在Python2最新版本: 2.7.15(已停止更新功能,2020停止支援) 現在Python3最新版本: 3.7.0 ==對於初學者,學習少一個版本是不錯的選擇,因為網路上資源多、套件比較穩定(3.6也算一個里程碑),所以我們會安裝**3.6.6**== ### Mac or Linux ~~如果你的電腦是是mac或是linux系統,恭喜你~你的電腦裡面已經內建好python了~~ 如果是mac或是linux系統,內建有Python2,不過我們要使用的是Python3所以還是需要下載安裝 [Python 3.6.6下載](https://www.python.org/downloads/release/python-366/) <img src="https://i.imgur.com/5ylJig6.png" style="width:70%;margin: 0 15%;"> 拉到最下面  挑你Mac OS版本符合的下載 點點點就裝好了(懶) 用Linux應不用教吧(XD ### Windows ~~請到 python的官方網站下載python,版本記得選取 **3.6.3**,這堂課不使用python2~~ 一樣這裡,[Python 3.6.6下載](https://www.python.org/downloads/release/python-366/) 最下面  x64系統載上面那三個,x32系統載下面那三個  勾選 Install Now 然後一直下一步 <font color="red">記得「Add Python 3.6 to PATH」一定要勾起來</font> ### 確認 安裝完之後,在terminal(Mac or Linux)或是在cmd(Windows)輸入 ```shell python3 --version ``` 會看到這樣的畫面  恭喜!你的 python 已經安裝成功了! ## 安裝Jupyter ### 介紹 <p align="center"> <img src="https://i.imgur.com/ovPENJ7.png" style="width: 70%; margin: 0px 15%;"> </p> Jupyter Project 前身是 IPython Project,2014年改名為Jupyter,主打三種程式語言,( Ju )lia、( Py )thon 和 ( R )語言,近幾年接受google、microsoft的贊助,越來越多企業使用他們的服務,是非常火熱、受歡迎的平台。 <img src="https://i.imgur.com/4CoKn56.png" width="24%"> <img src="https://i.imgur.com/dGurWaU.png" width="48%"> <img src="https://i.imgur.com/OxesprP.jpg" width="24%"> - Jupyter = Julia + Python + R 揪彼特是一個「互動式的筆記本」,有點類似 文字編輯器 + 直譯器,還可以配合Markdwon語法,讓程式碼和筆記結合,也支援多平台輸出,還有cells的設計符合模組化和單元測試的概念,非常便於使用。  - Jupyter介面 在爬蟲的課堂上,使用jupyter可以讓我們知道,我們爬到了什麼東西、如何進一步取出我們的資料,也能方便讓大家抓 BUG。 ### 安裝pip pip是一個專屬於python的套件管理器,可以下載社群上別人寫好的套件,來幫助你開發,這是python語言很重要的一環,也是他的特色。 jupyter也可以透過anaconda、virtualenv等虛擬環境來安裝,不過這堂課應該不會教到,而且後續也有一些套件要安裝,所以使用pip來安裝jupyter。 <img src="https://i.imgur.com/4yoeyum.png" width="48%"> <img src="https://i.imgur.com/qCBIE29.png" width="48%"> - Anaconda 和 virtualenv python3 的某一個版本之後,內建都會安裝pip,在command試看看執行這條指令 ```shell pip3 --version ``` 有出現這個畫面就是有安裝pip  沒有的話,到[這裡](https://pip.pypa.io/en/stable/installing/)下載吧~ ### 安裝jupyter 安裝好pip之後,剩下兩個步驟,後面的任務不像前面那麼麻煩,執行 ```shell python3 -m pip install jupyter ``` 或是 ```shell pip3 install jupyter ```  等他跑完,一切的安裝都ok了! ## 開始使用 終於裝完了!大家不要覺得喪氣,安裝環境通常都比較麻煩,但是好之後,後面要安裝其他套件都非常方便(感謝好用的pip)。 輸入我們最後一條指令 ```shell jupyter notebook ``` 他會自動在瀏覽器開啟jupyter notebook 一開始顯示的是你電腦裡面的資料夾  - jupyter介面 ~沒錯這張和上面一樣~ 我們可以開始練習python了! ## 其他內容 - install jupyter theme - setting jupyter default folder path - setting jupyter some variable
×
Sign in
Email
Password
Forgot password
or
Sign in via Google
Sign in via Facebook
Sign in via X(Twitter)
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
Continue with a different method
New to HackMD?
Sign up
By signing in, you agree to our
terms of service
.