Changing Python Versions
Applies to: Diskover 2.5.x+ (worker and web hosts)
Platforms: RHEL/Rocky 8-10, Ubuntu/Debian 22/24
Overview
Diskover uses a dedicated Python virtual environment at /opt/python-venv-diskover/ for all of its Python applications (Diskoverd, Diskover Admin, Celery, etc.). This keeps Diskover's Python runtime and dependencies isolated from the system Python, which avoids conflicts with OS packages and makes version changes straightforward.
When you need to change the Python version used by Diskover — for example, to move from Python 3.11 to 3.12 — you install the new Python, recreate the virtual environment, and reinstall Diskover's pip dependencies into it.
Note: Diskover also offers Ansible playbooks that handle Python version selection and venv creation automatically. If you'd like to use Ansible to manage this process, reach out to the Diskover team for assistance.
Manually Changing the Python Version
Follow the steps below to change the Python version on an existing Diskover host.
Step 1: Install the New Python Version
Replace 3.XX with your target version (e.g., 3.11, 3.12).
RHEL/Rocky:
dnf install python3.XX python3.XX-devel gcc
Ubuntu/Debian:
apt install python3.XX python3.XX-dev python3-venv gcc
Verify the installation:
python3.XX --version
You should see output like Python 3.XX.x.
Step 2: Remove the Existing Virtual Environment
Back up the existing venv (optional but recommended), then remove it:
cp -a /opt/python-venv-diskover /opt/python-venv-diskover.$(date +%Y%m%d) rm -rf /opt/python-venv-diskover
Step 3: Create a New Virtual Environment
Create the venv using the new Python version:
python3.XX -m venv /opt/python-venv-diskover
Verify the venv is using the correct Python:
/opt/python-venv-diskover/bin/python3 --version
This should show the new Python version.
Step 4: Reinstall Diskover pip Dependencies
Reinstall the Python packages required by each Diskover component on this host.
Worker host (diskoverd):
/opt/python-venv-diskover/bin/pip install -r /opt/diskover/requirements.txt
Web host (Diskover Admin):
/opt/python-venv-diskover/bin/pip install -r /var/www/diskover-admin/etc/requirements.txt
Step 5: Verify the PATH Configuration
Diskover adds the venv to the system PATH via /etc/profile.d/diskover-venv.sh so users do not need to activate the venv each time the user logs into the shell. Confirm this file exists and contains:
cat /etc/profile.d/diskover-venv.sh
Expected output:
# Add Diskover venv to PATH for CLI usage export PATH="/opt/python-venv-diskover/bin:$PATH"
If this file is missing, create it:
cat > /etc/profile.d/diskover-venv.sh << 'EOF' # Add Diskover venv to PATH for CLI usage export PATH="/opt/python-venv-diskover/bin:$PATH" EOF chmod 0644 /etc/profile.d/diskover-venv.sh
Reload the profile to pick up the change in your current session:
source /etc/profile.d/diskover-venv.sh
You should now see the python venv path listed:
which python3 /opt/python-venv-diskover/bin/python3
Step 6: Restart Diskover Services
Restart the services on this host so they pick up the new Python environment:
Worker host:
systemctl restart diskoverd systemctl restart celery
Web host:
systemctl restart diskover-admin
Step 7: Verify
Confirm the services are running with the new Python version:
systemctl status diskoverd /opt/python-venv-diskover/bin/python3 --version
Check the Diskover Admin web UI and Task Panel > Workers tab to confirm the worker is online.
Troubleshooting
Issue | Cause | Solution |
|---|---|---|
| Python version not installed | Install the package per Step 1 |
| pip dependencies not reinstalled | Run the pip install commands in Step 4 |
| Missing Python packages or wrong venv | Check |
| PATH not updated or shell not reloaded | Run |
Ansible recreates venv with wrong version | System Python is < 3.12 and desired version isn't installed | Install the target Python version before running the playbook, then remove the old venv so Ansible recreates it |
Comments
0 comments
Please sign in to leave a comment.