# 安裝及測試 Python 2.7 + VPython 6 > 作者:王一哲 > 日期:2022/2/5 <br /> ## 前言 由於我開始學習 VPython 時,正好處在 Python 2.7 + VPython 6 以及 Python 3 + VPython 7 兩者並存的時候,但是我一開始就選用比較新的版本,所以我之前就沒有寫安裝 Python 2.7 + VPython 6 的文件,這篇文章算是回來補過去留下的坑。以下的測試環境為 Windows 10 家用版。 <br /> ## 下載並安裝 Python 2.7 先從[Python 官方網站](https://www.python.org/)下載 Python 2.7,最後的更新版本為2.7.18,下載頁面為[https://www.python.org/downloads/release/python-2718/](https://www.python.org/downloads/release/python-2718/) ,我選擇的版本是 [Windows x86-64 MSI installer](https://www.python.org/ftp/python/2.7.18/python-2.7.18.amd64.msi)。 <img style="display: block; margin-left: auto; margin-right: auto" height="100%" width="100%" src="https://imgur.com/HLsQdlj.png"> <div style="text-align:center">Python 2.7.18 下載頁面</div> <br /><br /> 找到剛才下載的安裝檔,在檔案上按滑鼠右鍵選擇以系統管理員身分執行。 <img style="display: block; margin-left: auto; margin-right: auto" height="40%" width="40%" src="https://imgur.com/RVPjUL8.png"> <br /><br /> 我通常會選擇為所有使用者安裝 (Instal for all users),點擊 **Next** 繼續安裝。 <img style="display: block; margin-left: auto; margin-right: auto" height="60%" width="60%" src="https://imgur.com/N3nr0nm.png"> <br /><br /> 預設的安裝路徑為 **C:\Python27\\**,建議採用預設值,點擊 **Next** 繼續安裝。 <img style="display: block; margin-left: auto; margin-right: auto" height="60%" width="60%" src="https://imgur.com/KuHwGOY.png"> <br /><br /> 建議採用預設值,點擊 **Next** 繼續安裝。 <img style="display: block; margin-left: auto; margin-right: auto" height="60%" width="60%" src="https://imgur.com/DBJDAO8.png"> <br /><br /> 安裝中,需要等幾分鐘。 <img style="display: block; margin-left: auto; margin-right: auto" height="60%" width="60%" src="https://imgur.com/VZdCWzf.png"> <br /><br /> 安裝完畢,點擊 **Finish** 離開安裝程式。 <img style="display: block; margin-left: auto; margin-right: auto" height="60%" width="60%" src="https://imgur.com/mywyquE.png"> <br /><br /> ## 設定環境變數 從左下角搜尋 **環境變數**,點擊 **編輯系統環境變數**。 <img style="display: block; margin-left: auto; margin-right: auto" height="70%" width="70%" src="https://imgur.com/PqntrYV.png"> <br /><br /> 點擊下方的 **環境變數(N)...**。 <img style="display: block; margin-left: auto; margin-right: auto" height="60%" width="60%" src="https://imgur.com/EeS2ztN.png"> <br /><br /> 點擊下方系統變數中的 **Path**,再點擊 **編輯(I)...**。 <img style="display: block; margin-left: auto; margin-right: auto" height="60%" width="60%" src="https://imgur.com/eqc8x69.png"> <br /><br /> 點擊右方的 **新增(N)**。 <img style="display: block; margin-left: auto; margin-right: auto" height="60%" width="60%" src="https://imgur.com/KYqnrhP.png"> <br /><br /> 新增兩個路徑 **C:\Python27** 及 **C:\Python27\Scripts**,再點擊下方的 **確定**。 <img style="display: block; margin-left: auto; margin-right: auto" height="60%" width="60%" src="https://imgur.com/FPb5tfL.png"> <br /><br /> 在 Windows 開始符號上點擊滑鼠右鍵,開啟 **Windows PowerShell**。 <img style="display: block; margin-left: auto; margin-right: auto" height="50%" width="50%" src="https://imgur.com/tpP2wca.png"> <br /><br /> 輸入指令 **python --versionh**,如果看到系統回傳 **Python 2.7.18** 就成功了。 <img style="display: block; margin-left: auto; margin-right: auto" height="70%" width="70%" src="https://imgur.com/WS9ZLQb.png"> <br /><br /> ## 安裝 VPython 6 由於 VPython 6 是較舊的版本,最好不要使用 pip 指令安裝套件,[這個網頁](http://www-meg.phys.cmu.edu/physics_33151/vpython-old.html)有舊版套件的下載連結。我選擇的版本是 [VPython-Win-64-Py2.7-6.11](http://sourceforge.net/projects/vpythonwx/files/6.11-release/VPython-Win-64-Py2.7-6.11.exe/download),找到剛才下載的安裝檔,在檔案上按滑鼠右鍵選擇以系統管理員身分執行。 <img style="display: block; margin-left: auto; margin-right: auto" height="40%" width="40%" src="https://imgur.com/x40nLAE.png"> <br /><br /> 點擊 **Next** 繼續安裝。 <img style="display: block; margin-left: auto; margin-right: auto" height="60%" width="60%" src="https://imgur.com/0FEJqJx.png"> <br /><br /> 建議採用預設值,點擊 **Next** 繼續安裝。 <img style="display: block; margin-left: auto; margin-right: auto" height="60%" width="60%" src="https://imgur.com/bpkdI6f.png"> <br /><br /> 在桌面上產生 **VIDLE** 的捷徑,點擊 **Next** 繼續安裝。 <img style="display: block; margin-left: auto; margin-right: auto" height="60%" width="60%" src="https://imgur.com/63c90IV.png"> <br /><br /> 點擊 **Install** 正式開始安裝套件。 <img style="display: block; margin-left: auto; margin-right: auto" height="60%" width="60%" src="https://imgur.com/KUUiD0c.png"> <br /><br /> 安裝中,需要等幾分鐘。 <img style="display: block; margin-left: auto; margin-right: auto" height="60%" width="60%" src="https://imgur.com/OA7xZV3.png"> <br /><br /> 安裝完畢,點擊 **Finish** 離開安裝程式。 <img style="display: block; margin-left: auto; margin-right: auto" height="60%" width="60%" src="https://imgur.com/NPReXbA.png"> <br /><br /> 安裝完畢後桌面上會出現 VIDLE 的捷徑,使用捷徑開啟 VIDLE。 <img style="display: block; margin-left: auto; margin-right: auto" height="15%" width="15%" src="https://imgur.com/vyUuHeu.png"> <br /><br /> 進到 VIDLE,會先開啟一個空白的檔案。 <img style="display: block; margin-left: auto; margin-right: auto" height="70%" width="70%" src="https://imgur.com/T3Q4Ynj.png"> <br /><br /> 從上方的選單依序點選 **File** ⇒ **Open** 或是按 **Ctrl+O** 開啟檔案。 <img style="display: block; margin-left: auto; margin-right: auto" height="70%" width="70%" src="https://imgur.com/5j1KiBO.png"> <br /><br /> 剛才安裝套件時順便安裝了許多的範例程式,路徑為 **C:\Python27\Lib\site-packages\visual\examples\\**,這裡選擇第一個檔案 bounce.py。 <img style="display: block; margin-left: auto; margin-right: auto" height="70%" width="70%" src="https://imgur.com/TXUqmIX.png"> <br /> <img style="display: block; margin-left: auto; margin-right: auto" height="70%" width="70%" src="https://imgur.com/6P1BCFM.png"> <br /><br /> 按 **F5** 執行程式,如果出現這樣的視窗就代表 VPython 6 可以正常運作了。 <img style="display: block; margin-left: auto; margin-right: auto" height="70%" width="70%" src="https://imgur.com/m2Oiq9d.png"> <br /><br /> ## 結語 雖然這個版本目前仍然可以運作,但是 Python 2.7 和 VPython 6 已經不再更新,還是建議改用 Python 3 和 VPython 7,安裝過程請參考我的另一篇文章〈[安裝及測試 VPython](https://hackmd.io/@yizhewang/BJ2jKMbf7)〉,如果不想安裝 VPython 7 甚至可以用線上版的 [GlowScript IDE](https://www.glowscript.org/)。 <br /> --- ###### tags: `VPython`