Skip to content
Search Fedora

    Browse this documentation

    Python on Fedora: venv, pipx, uv and domestic mirrors

    Terminal window
    python3 -V
    rpm -q python3
    Python 3.15.0rc1
    python3-3.15.0~rc1-1.fc45.x86_64

    Fedora’s Python lives in /usr and sys.prefix is /usr — it is a system component, and dnf itself depends on it.

    System python3, versioned python3.13/3.14 and venv side by side

    Never run sudo pip install. Not out of taste:

    • it writes into /usr/lib/python3.15/site-packages, mixing with rpm-managed files
    • dnf upgrade may overwrite or fail on the conflict
    • it damages the system toolchain itself (dnf5 is written in Python)

    Use one of the three isolation layers below instead.

    Terminal window
    mkdir -p ~/proj && cd ~/proj
    python3 -m venv .venv
    source .venv/bin/activate
    pip install requests
    Terminal window
    which python
    /home/labuser/proj/.venv/bin/python

    Leave with deactivate.

    venv isolates packages only; the interpreter is still the system 3.15. That covers most projects.

    Configuration precedence: project pip.conf < user ~/.config/pip/pip.conf < global /etc/pip.conf.

    Terminal window
    mkdir -p ~/.config/pip
    cat > ~/.config/pip/pip.conf <<'EOF'
    [global]
    index-url = https://pypi.tuna.tsinghua.edu.cn/simple
    EOF

    Verify:

    Terminal window
    pip config list
    global.index-url='https://pypi.tuna.tsinghua.edu.cn/simple'

    For a one-off, use -i:

    Terminal window
    pip install -i https://pypi.tuna.tsinghua.edu.cn/simple requests

    Whether the mirror is actually faster depends on your link; see domestic mirrors for how to measure.

    Some packages are applications, not libraries (black, httpie, ansible). They need their own environment or they fight with project dependencies:

    Terminal window
    sudo dnf install pipx
    pipx ensurepath
    pipx install black
    black --version

    pipx list shows each tool’s isolated environment; pipx upgrade-all upgrades them together.

    Fedora’s default is one Python (python3 = 3.15.0rc1), but the repo does ship versioned packages. Measured:

    Terminal window
    sudo dnf install python3.13 python3.14
    python3.13 --version # Python 3.13.15
    python3.14 --version # Python 3.14.7
    python3 --version # Python 3.15.0rc1

    All three coexist under /usr/bin/. See multiple versions for the full matrix.

    For anything older (3.12 and earlier), or when you need more control:

    Terminal window
    curl -LsSf https://astral.sh/uv/install.sh | sh
    Terminal window
    uv python install 3.12
    uv python list
    uv venv --python 3.12

    uv manages interpreter downloads in its own cache and never touches the system Python. pyenv works too:

    Terminal window
    curl https://pyenv.run | bash
    pyenv install 3.12.7
    pyenv global 3.12.7
    NeedUse
    project dependenciesvenv
    CLI tools (black/httpie/ansible)pipx
    another interpreter versionuv or pyenv
    a fully separate systemcontainers (see containers)
    pinned versions in CIcontainer images
    SymptomCause
    pip: command not foundpip not installed; use python3 -m pip or dnf install python3-pip
    error: externally-managed-environmentFedora blocking writes to system site-packages — exactly why venv exists
    ModuleNotFoundError for something you installedinstalled into another interpreter or venv; check which python
    commands missing inside a venvforgot source .venv/bin/activate
    system tools report Python errorsa past sudo pip polluted system packages; check with rpm -V python3-libs