使用 Anaconda 安裝 VPython
作者:王一哲
日期:2023年1月4日
Anaconda
這是一套開放原始碼的 Python 與 R 語言發行版,官方網站為 https://www.anaconda.com/ 。它包含比較便於操作的套件管理工具,可以支援 Windows、MacOS、Linux 三種作業系統。理論上也可以安裝 VPython,以下是我的測試過程。
Windows 10
安裝 Anaconda
測試環境為 Windows 10 企業版,使用的軟體為 Anaconda + Python 3.9 + Windows 64位元版本。於下載好的 Anaconda 安裝檔上按滑鼠右鍵,選擇以系統管理員身分執行,安裝過程基本上就是一直按 Enter 即可。
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Anaconda 安裝步驟1:點擊 Next 即可
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Anaconda 安裝步驟2:點擊 I Agree
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Anaconda 安裝步驟3:可以選擇只安裝給這個使用者 Just Me 或是所有使用者 All Users。
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Anaconda 安裝步驟4:選擇安裝路徑,採用預設值即可。
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Anaconda 安裝步驟5:預設已選取第2個選項,點擊 Install。
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Anaconda 安裝步驟6:安裝中,需要等一段時間。
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Anaconda 安裝步驟7:安裝完畢
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Anaconda 安裝步驟8:不理它,點擊 Next。
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Anaconda 安裝步驟9:如果勾選這兩個選項會開啟線上的說明書,點擊 Finish 完成安裝。
安裝 Anaconda 時會同時安裝很多套件,由開始選單啟動 Anaconda Prompt,使用以下指令列出已安裝的套件
目前安裝的 Python 版本為 3.9.13。
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
由開始選單啟動 Anaconda Prompt
安裝 Anaconda 時也會安裝一套名為 Spyder 的 IDE,目前安裝的 Spyder 版本為 5.2.2。按照慣例,先來個 Hello World!
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
由開始選單啟動 Spyder
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
於 Spyder 中執行 Hello World!
如果想要使用 Python 自帶的 IDLE,要先開啟 Anaconda Prompt,再執行指令 idle,這樣才不會在引入函式庫時遇到問題。
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
由 Anaconda Prompt 啟動 IDLE
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
於 IDLE 中執行 Hello World!
安裝 VPython
接下來要安裝 VPython 套件,以下的安裝指令是參考 Anaconda 的官方說明書。於開始選單搜尋 Anaconda Prompt,並選擇以系統管理員身分執行。如果使用以下指令安裝 VPython 會出現錯誤訊息。
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
於 Anaconda Prompt 中安裝 VPython 失敗
必須改用以下的指令安裝,目前安裝的 VPython 版本為 7.6.4。
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
於 Anaconda Prompt 中安裝 VPython
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
於 Anaconda Prompt 中安裝 VPython 成功
接下來在 Spyder 或是 IDLE 中貼上以下的程式碼,測試是否已經正確安裝 VPython,如果能夠跑出動畫就成功了。
雖然程式碼的左側有許多的驚嘆號,顯示 Spyder 找不到名為 vpython 的套件,或是找不到名為 canvas、vec、box、color、rate 等物件,但是按 F5 仍然可以跑出動畫。
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
於 Spyder 中執行 VPython 動畫
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
於 IDLE 中執行 VPython 動畫
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
VPython 動畫執行畫面
Ubuntu 22.04
安裝 Anaconda
測試環境為 Ubuntu 22.04.1 LTS (Jammy Jellyfish),使用的軟體為 Anaconda + Python 3.9 + Linux 64位元版本。安裝步驟主要是參考 Anaconda 官方說明書。依照開啟指令列介面,安裝需要使用的套件
但是 Ubuntu 22.04 中已經安裝了大部分的套件,實際上只會再安裝 libegl1-mesa 及 libgl1-mesa-glx 兩個套件。
由以下的連結下載 Linux 版安裝檔,我下載的版本是 Anaconda3-2022.10-Linux-x86_64.sh,檔案大小約 738 MB,需要等一段時間。在指令列介面中先切換到存放安裝檔的資料夾中,使用以下指令檢驗檔案的完整性
依照官方說明書,回傳值應該是
如果回傳值不同要重新下載檔案。
接下來使用此指令安裝 Anaconda
安裝過程基本上都採用預設值即可。安裝完成後,關閉再開啟指令列介面,輸入 spyder 或是 idle3 開啟指定的 IDE,一樣先執行一下 Hello World!。
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
於 Ubuntu 22.04 的 Spyder 中執行 Hello World!
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
於 Ubuntu 22.04 的 IDLE 中執行 Hello World!
安裝 VPython
開啟指令列介面,輸入以下指令安裝 VPython
但是在等了很久之後會出現以下的錯誤訊息
後來我在 Stack Overflow 網站上找到類似的文章,執行以下指令就能夠成功地安裝 VPython。
於指令列介面中開啟 Spyder 或是 IDLE,貼入測試用的 VPython 程式碼,再按 F5 執行,可以成功地跑出動畫。
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
於 Ubuntu 22.04 的 Spyder 中執行 VPython 動畫
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
於 Ubuntu 22.04 的 IDLE 中執行 VPython 動畫
結語
雖然 Anaconda 似乎很方便,但是我還是比較偏好只安裝需要使用的套件就好,建議初學者還是依照我的另一篇文章〈安裝及測試 VPython〉的作法會比較順利。