Home/Blog/Fix lscpd / psutil error

CyberPanel lscpd failed: fix ImportError psutil and a broken Python venv after upgrade

Updated October 28, 2026By Dr. S9 min read

This is the failure that catches most CyberPanel admins after an innocent apt upgrade or dnf update: websites keep working, but the panel on port 8090 answers 503, systemctl status lscpd says failed, and the log has a line like:

ModuleNotFoundError: No module named 'psutil'
# or
ImportError: /usr/local/CyberCP/lib/python3.10/site-packages/psutil/_psutil_linux...so: invalid ELF header
# or
ImportError: cannot import name ... undefined symbol

The instinct is pip install psutil. Sometimes it works. Often it does nothing, because the real problem is one layer down. This guide goes through the causes in the order that avoids making it worse.

Why this happens

CyberPanel runs on Django inside its own virtual environment at /usr/local/CyberCP, with its own interpreter at /usr/local/CyberCP/bin/python and its own pip. Some dependencies, psutil among them, are compiled C extensions tied to a specific Python version. Three things routinely break that:

Confirm and classify the error

systemctl status lscpd --no-pager
journalctl -xeu lscpd -n 40 --no-pager
tail -n 40 /usr/local/lscp/logs/error.log

/usr/local/CyberCP/bin/python --version
/usr/local/CyberCP/bin/python -c "import psutil; print(psutil.__version__)"
/usr/local/CyberCP/bin/pip --version
python3 --version
df -h / ; df -i /
OutputCause
python: No such file or directory for the venv interpreterVenv interpreter gone (system Python removed or replaced)
Venv Python version differs from the one it was built for, import failsPython version mismatch after OS update
pip --version fails or throws a tracebackpip itself is broken; must be fixed before any install
invalid ELF header, file too short, undefined symbolCorrupt compiled module
No module named 'psutil' and pip worksSimply not installed in the venv
pip install fails with gcc / Python.h errorsBuild tools missing, pip is trying to compile

Disk first, always

If / is above about 90% or inodes are exhausted, stop and clean the disk. Installing anything on a full disk produces exactly the corrupt file you are trying to replace. This single rule prevents most repeat failures.

Fix by cause

Every command below uses the venv's own pip. Never pip3, never sudo pip.

pip is broken

/usr/local/CyberCP/bin/python -m ensurepip --upgrade
# if ensurepip is unavailable:
curl -sS https://bootstrap.pypa.io/get-pip.py -o /root/get-pip.py
/usr/local/CyberCP/bin/python /root/get-pip.py
/usr/local/CyberCP/bin/pip --version

Once pip works, continue to whichever of the next cases applies; a working pip does not by itself fix the import.

Corrupt module

/usr/local/CyberCP/bin/pip install --force-reinstall --no-cache-dir psutil
systemctl restart lscpd

--no-cache-dir matters: pip's cache may hold the same corrupt wheel. If metadata is damaged and force-reinstall still fails, remove the package directory and install clean:

/usr/local/CyberCP/bin/pip uninstall -y psutil
rm -rf /usr/local/CyberCP/lib/python3*/site-packages/psutil*
/usr/local/CyberCP/bin/pip install --no-cache-dir psutil
systemctl restart lscpd

Module simply missing

/usr/local/CyberCP/bin/pip install --no-cache-dir psutil
systemctl restart lscpd

If one module vanished, others may have too. Reinstall the panel's full requirement set in place (it skips what is already correct):

REQ=/usr/local/CyberCP/requirments.txt; [ -f "$REQ" ] || REQ=/usr/local/CyberCP/requirements.txt
/usr/local/CyberCP/bin/pip install --no-cache-dir -r "$REQ"
systemctl restart lscpd

Build tools missing

apt-get install -y gcc python3-dev        # Ubuntu
dnf install -y gcc python3-devel          # AlmaLinux / Rocky
/usr/local/CyberCP/bin/pip install --no-cache-dir psutil

Rebuilding the venv (last resort)

Use this when the interpreter is missing, the Python version changed, or every lighter fix above has failed. It is a level-3 operation: the panel is down for a few minutes, websites are unaffected, and you need a backup before you start.

cp -a /usr/local/CyberCP/lib /root/CyberCP-lib-backup-$(date +%F)

cd /usr/local/CyberCP
mv lib lib.broken.$(date +%s)
python3 -m venv --upgrade-deps /usr/local/CyberCP

REQ=/usr/local/CyberCP/requirments.txt; [ -f "$REQ" ] || REQ=/usr/local/CyberCP/requirements.txt
/usr/local/CyberCP/bin/pip install --no-cache-dir -r "$REQ"

systemctl restart lscpd

If the rebuild fails on a dependency, restore the old lib directory from the backup so you are no worse off, and take the error to the CyberPanel forum or support with the exact traceback. Re-running the official upgrade script is the other sanctioned route; it rebuilds the environment as part of the upgrade.

Do not reinstall CyberPanel to solve this. A fresh install on a live server does not repair the venv; it resets the panel and leaves it out of sync with your existing sites.

Verify

/usr/local/CyberCP/bin/python -c "import django, psutil; print('imports ok')"
systemctl is-active lscpd
curl -sk -o /dev/null -w "%{http_code}\n" https://127.0.0.1:8090/

Imports succeed, lscpd is active and the panel answers 200 or 302. Log in and open a site's page in the panel to confirm the database connection too.

Dr. S

Self-taught developer and SEO specialist who runs CyberPanel and OpenLiteSpeed servers for his own SaaS tools and client sites. VPS Medic is built from the repairs he kept doing by hand on those servers.

The same ladder, automated

VPS Medic classifies the error, checks the disk, repairs pip, reinstalls only the broken module, and rebuilds the venv only with your confirmation and a backup. The whole run streams to your phone.

Download VPS Medic — free 3-day trial