Ubuntu 24.04에 Python 3.11을 설치하려면 터미널을 열고 sudo apt update로 시스템을 업데이트한 후 deadsnakes PPA를 추가하여 sudo apt install python3.11 명령어로 설치합니다. 설치 후에는 python3.11 --version으로 설치된 버전을 확인하고, python3-pip 패키지를 설치하여 pip를 사용할 수 있습니다.
1. 시스템 업데이트 및 기본 패키지 설치
터미널을 엽니다.
다음 명령어로 패키지 목록을 업데이트합니다:
bash
sudo apt update
Python 설치에 필요한 software-properties-common 패키지를 설치합니다:
bash
sudo apt install software-properties-common
To set Python 3.11 as an alternative for python3 on Ubuntu 24.04 using update-alternatives, assuming Python 3.11 is already installed, follow these steps:
1. Add Python 3.11 as an alternative:
코드
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1
/usr/bin/python3: This is the symbolic link that update-alternatives will manage.
python3: This is the name of the alternative group.
/usr/bin/python3.11: This is the path to the Python 3.11 executable.
1: This is the priority. Higher numbers indicate higher priority in automatic mode.
2. Configure the default Python 3 version:
코드
sudo update-alternatives --config python3
This command will display a list of available Python 3 alternatives and prompt you to choose the desired version. Enter the number corresponding to Python 3.11 to select it.
3. Verify the change:
코드
python3 --version
This command should now output Python 3.11.x, confirming that Python 3.11 is the default version for the python3 command.
Important Considerations:
System Python: Be cautious when changing the default system Python. Many Ubuntu system tools rely on a specific Python version (typically Python 3.12 on Ubuntu 24.04). Directly altering the system's default Python can lead to system instability.
Virtual Environments: For development projects, it is highly recommended to use virtual environments (e.g., venv, conda, pyenv) to manage Python versions and dependencies without affecting the system-wide Python installation. This approach allows you to use Python 3.11 (or any other version) for specific projects without risking system issues.
Deadsnakes PPA: If Python 3.11 is not already installed on your system, you can install it using the deadsnakes PPA, which provides more recent Python versions for Ubuntu:
코드
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.11