201 lines
3.4 KiB
Markdown
201 lines
3.4 KiB
Markdown
# Python Installation - Fedora/RHEL/CentOS
|
|
|
|
## Check Current Version
|
|
|
|
```bash
|
|
python3 --version
|
|
```
|
|
|
|
If you see Python 3.11+, you're good to go! [← Back to main skill](../SKILL.md#step-2-create-virtual-environment)
|
|
|
|
---
|
|
|
|
## Installation Methods
|
|
|
|
### Option 1: DNF Package Manager (Fedora)
|
|
|
|
**Fedora usually includes recent Python versions:**
|
|
|
|
```bash
|
|
sudo dnf install python3.11 python3.11-devel python3.11-pip -y
|
|
```
|
|
|
|
**For Python 3.12/3.13 (if available):**
|
|
```bash
|
|
sudo dnf install python3.13 python3.13-devel -y
|
|
```
|
|
|
|
**Verify:**
|
|
```bash
|
|
python3.13 --version
|
|
```
|
|
|
|
---
|
|
|
|
### Option 2: RHEL/CentOS (Using EPEL)
|
|
|
|
**Enable EPEL repository:**
|
|
```bash
|
|
sudo dnf install epel-release -y
|
|
sudo dnf update -y
|
|
```
|
|
|
|
**Install Python:**
|
|
```bash
|
|
sudo dnf install python3.11 python3.11-devel python3.11-pip -y
|
|
```
|
|
|
|
---
|
|
|
|
### Option 3: Build from Source (Advanced)
|
|
|
|
**Install build dependencies:**
|
|
```bash
|
|
sudo dnf groupinstall "Development Tools" -y
|
|
sudo dnf install gcc openssl-devel bzip2-devel libffi-devel zlib-devel -y
|
|
```
|
|
|
|
**Download and build Python 3.13:**
|
|
```bash
|
|
cd /tmp
|
|
wget https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz
|
|
tar xzf Python-3.13.0.tgz
|
|
cd Python-3.13.0
|
|
./configure --enable-optimizations
|
|
make -j $(nproc)
|
|
sudo make altinstall # Don't use 'install', use 'altinstall' to avoid replacing system python
|
|
```
|
|
|
|
**Verify:**
|
|
```bash
|
|
python3.13 --version
|
|
```
|
|
|
|
---
|
|
|
|
### Option 4: pyenv (Multiple Versions)
|
|
|
|
**Install dependencies:**
|
|
```bash
|
|
sudo dnf install gcc make patch zlib-devel bzip2 bzip2-devel \
|
|
readline-devel sqlite sqlite-devel openssl-devel tk-devel \
|
|
libffi-devel xz-devel -y
|
|
```
|
|
|
|
**Install pyenv:**
|
|
```bash
|
|
curl https://pyenv.run | bash
|
|
```
|
|
|
|
**Add to ~/.bashrc:**
|
|
```bash
|
|
export PYENV_ROOT="$HOME/.pyenv"
|
|
export PATH="$PYENV_ROOT/bin:$PATH"
|
|
eval "$(pyenv init --path)"
|
|
eval "$(pyenv init -)"
|
|
```
|
|
|
|
**Reload shell:**
|
|
```bash
|
|
source ~/.bashrc
|
|
```
|
|
|
|
**Install Python 3.13:**
|
|
```bash
|
|
pyenv install 3.13.0
|
|
pyenv global 3.13.0
|
|
```
|
|
|
|
**Verify:**
|
|
```bash
|
|
python --version
|
|
```
|
|
|
|
---
|
|
|
|
## Set Default Python Version
|
|
|
|
**Check available versions:**
|
|
```bash
|
|
ls /usr/bin/python*
|
|
```
|
|
|
|
**Set alternative:**
|
|
```bash
|
|
sudo alternatives --install /usr/bin/python3 python3 /usr/bin/python3.13 1
|
|
sudo alternatives --config python3
|
|
```
|
|
|
|
---
|
|
|
|
## Install pip
|
|
|
|
**Usually installed with python3:**
|
|
```bash
|
|
python3 -m pip --version
|
|
```
|
|
|
|
**If missing:**
|
|
```bash
|
|
sudo dnf install python3-pip -y
|
|
```
|
|
|
|
**Upgrade pip:**
|
|
```bash
|
|
python3 -m pip install --user --upgrade pip
|
|
```
|
|
|
|
---
|
|
|
|
## Troubleshooting
|
|
|
|
### Issue: `No package python3.13 available`
|
|
|
|
**Solutions:**
|
|
1. Check Fedora version: `cat /etc/fedora-release`
|
|
2. Update system: `sudo dnf update -y`
|
|
3. Try older version: `sudo dnf install python3.11 -y`
|
|
4. Use pyenv (Option 4 above)
|
|
|
|
### Issue: `No module named 'venv'`
|
|
|
|
**Install venv (usually included):**
|
|
```bash
|
|
sudo dnf install python3.13-venv -y
|
|
```
|
|
|
|
### Issue: Development headers missing
|
|
|
|
**Install development package:**
|
|
```bash
|
|
sudo dnf install python3.13-devel -y
|
|
```
|
|
|
|
### Issue: Permission denied
|
|
|
|
**Don't use sudo with pip inside venv:**
|
|
```bash
|
|
python3 -m venv venv
|
|
source venv/bin/activate
|
|
pip install <package> # No sudo needed
|
|
```
|
|
|
|
---
|
|
|
|
## Verification Checklist
|
|
|
|
- [ ] `python3 --version` shows 3.11+
|
|
- [ ] `python3 -m venv --help` works
|
|
- [ ] `python3 -m pip --version` works
|
|
- [ ] Can create test venv: `python3 -m venv test_venv`
|
|
- [ ] Can activate: `source test_venv/bin/activate`
|
|
|
|
**Clean up test:**
|
|
```bash
|
|
rm -rf test_venv
|
|
```
|
|
|
|
---
|
|
|
|
[← Back to django-project-setup](../SKILL.md)
|