Python Update Linux |work| Today

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh bash Miniconda3-latest-Linux-x86_64.sh conda install python=3.12 Never run:

python3.12 -m venv myprojectenv source myprojectenv/bin/activate | Issue | Solution | |--------|----------| | ModuleNotFoundError: No module named 'distutils' | Install python3.12-distutils or python3-distutils from your package manager | | pip not found after source install | Run python3.12 -m ensurepip or python3.12 -m pip install --upgrade pip | | System Python broken | Boot from live USB, chroot, and reinstall the original Python version via package manager | | ssl module missing after source compile | Install libssl-dev / openssl-devel and recompile Python | Summary Table: Best Update Method by Use Case | Use Case | Recommended Method | |----------|--------------------| | Keep system secure, don't need latest features | sudo apt upgrade python3 (package manager) | | Need a specific newer version not in repos | deadsnakes PPA (Ubuntu) / EPEL (RHEL) | | Need absolute latest patch release | Compile from source with altinstall | | Development with multiple Python versions | pyenv | | Data science / ML projects | conda | Final advice: Never replace your system’s default Python 3. Instead, install additional versions alongside it and use virtual environments or version managers to keep your projects isolated.

python3.12 my_script.py Or use update-alternatives (Debian/Ubuntu):

which python3 ls -l /usr/bin/python* Most stable method. It updates Python only to the latest version provided by your distribution’s official repositories – not the absolute latest upstream release. Debian / Ubuntu / Linux Mint sudo apt update sudo apt upgrade python3 To see available Python versions:

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1 sudo update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.12 2 sudo update-alternatives --config python3 After updating Python, update pip :

ls /usr/bin/python* /usr/local/bin/python* ~/.pyenv/versions/ 2>/dev/null Switch temporarily:

sudo add-apt-repository ppa:deadsnakes/ppa sudo apt update sudo apt install python3.12 Fedora (usually has recent Python versions):

sudo dnf upgrade python3 – default repos are outdated. Use EPEL or source compilation.

オススメ
こちらの記事もどうぞ

Python Update Linux |work| Today

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh bash Miniconda3-latest-Linux-x86_64.sh conda install python=3.12 Never run:

python3.12 -m venv myprojectenv source myprojectenv/bin/activate | Issue | Solution | |--------|----------| | ModuleNotFoundError: No module named 'distutils' | Install python3.12-distutils or python3-distutils from your package manager | | pip not found after source install | Run python3.12 -m ensurepip or python3.12 -m pip install --upgrade pip | | System Python broken | Boot from live USB, chroot, and reinstall the original Python version via package manager | | ssl module missing after source compile | Install libssl-dev / openssl-devel and recompile Python | Summary Table: Best Update Method by Use Case | Use Case | Recommended Method | |----------|--------------------| | Keep system secure, don't need latest features | sudo apt upgrade python3 (package manager) | | Need a specific newer version not in repos | deadsnakes PPA (Ubuntu) / EPEL (RHEL) | | Need absolute latest patch release | Compile from source with altinstall | | Development with multiple Python versions | pyenv | | Data science / ML projects | conda | Final advice: Never replace your system’s default Python 3. Instead, install additional versions alongside it and use virtual environments or version managers to keep your projects isolated.

python3.12 my_script.py Or use update-alternatives (Debian/Ubuntu): python update linux

which python3 ls -l /usr/bin/python* Most stable method. It updates Python only to the latest version provided by your distribution’s official repositories – not the absolute latest upstream release. Debian / Ubuntu / Linux Mint sudo apt update sudo apt upgrade python3 To see available Python versions:

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1 sudo update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.12 2 sudo update-alternatives --config python3 After updating Python, update pip : wget https://repo

ls /usr/bin/python* /usr/local/bin/python* ~/.pyenv/versions/ 2>/dev/null Switch temporarily:

sudo add-apt-repository ppa:deadsnakes/ppa sudo apt update sudo apt install python3.12 Fedora (usually has recent Python versions): It updates Python only to the latest version

sudo dnf upgrade python3 – default repos are outdated. Use EPEL or source compilation.

記事URLをコピーしました