# Python重灌懶人包 ## 為什麼要重灌Python? 1. 遇到安裝套件問題 2. 需要更新Python版本 3. 沒別的原因就想重灌 ## 重灌步驟: 1. 首先刪掉原版本的Python(用最徹底的方式刪掉,否則後來要清除殘留檔案比較麻煩) `sudo apt-get --purge autoremove python3`  2. 查詢Python是否還留著,最簡單的方法是用 `python --version` 或 `python3 --version`  3. 確定刪除了之後,重灌Python 樹莓派是Debian系統衍生產品Ubuntu,用`apt`: `sudo apt-get install python3` Red Hat和衍生產品,用`yum`: `sudo yum install python3` SUSE和衍生產品,用`zypper`: `sudo zypper install python3` 4. 這時候打`python3 --version`會出現最新版本python3,`python --version`會被退回說`/bin/python`不存在,所以要把python和python3的資料夾連結起來(這是為了vs code按run鍵可以自動執行/bin/python/...)   方法如下: * 首先刪除python在bin的資料夾,因為那是一個損壞的資料夾 `sudo rm -rf /usr/bin/python` * 再連結python3.9(或其他版本)到python `sudo ln -s /usr/bin/python3.9 /usr/bin/python`  5. 你還會需要重灌pip套件,之後安裝其他套件的時候會用到 * 檢查 `sudo apt update` * 然後安裝pip `sudo apt install python3-pip` ## 參考來源 * [pip3: command not found](https://stackoverflow.com/questions/48014769/pip3-command-not-found) * [How do I reinstall a directory in /usr/bin/python](https://stackoverflow.com/questions/15236832/how-do-i-reinstall-a-directory-in-usr-bin-python) * [在 Linux 上安裝 Python、pip 和 EB CLI](https://docs.aws.amazon.com/zh_tw/elasticbeanstalk/latest/dg/eb-cli3-install-linux.html)
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up