Install Python in an offline environment
If you have a system in an offline environment (either air-gapped or without access to systems outside of a specific network), then these instructions may suit your use case.
Requirements
- a system access to the internet and
curlinstalled - a user with
sudopermissions on the offline system
Download the right file for your offline system
Determine the architecture of the offline system
Record the CPU architecture of the system which will have Python installed on it.
#! /bin/bash
ARCH=$(uname -i)
if [ $ARCH == "arm64" ]; then
ARCH="aarch64"
fi
echo $ARCHDownload the file using the online system
Using the system that has network access, set the $ARCH variable collected from the offline system, and the version of Python, then retrieve the Python installation file.
#!/bin/bash
PYTHON_VERSION=3.13.14
ARCH=
# download master json file
echo "Getting download information..."
curl -L -o python-versions.json https://raw.githubusercontent.com/astral-sh/uv/refs/heads/main/crates/uv-python/download-metadata.json
# get download url for Python version
PYTHON_PACKAGE="cpython-${PYTHON_VERSION}-linux-${ARCH}-gnu"
DOWNLOAD_URL=$(grep -A 20 "\"${PYTHON_PACKAGE}\":" python-versions.json | \
grep -m 1 "\"url\":" | sed -E 's/.*"url": ?"([^"]+)".*/\1/')
# download installation tarball, quotes to get %2B correct
curl -L -o python-"${PYTHON_VERSION}".tgz "${DOWNLOAD_URL}"Install Python in your offline environment
Copy the file python-$PYTHON_VERSION.tgz to the air-gapped system, set the Python version, and run the following commands:
PYTHON_VERSION=3.13.14
# create canonical directory extract tar ball
sudo mkdir -p /opt/python/"${PYTHON_VERSION}"
sudo tar xvf python-"${PYTHON_VERSION}".tgz \
-C /opt/python/"${PYTHON_VERSION}" --strip-components=1Verify Python installation
Verify that Python is installed by running the following command:
/opt/python/"${PYTHON_VERSION}"/bin/python --versionCustomizing the package repository
If using an alternative source of Python packages, such as Posit Package Manager, configure the package installation client in your Posit product:
See the Install Python documentation for other optional configuration steps.