pf9-hostagent Failing With Error "No module named 'apt_pkg'"
Problem
The host is disconnected from Management Plane and pf9-hostagent service is failing and hostagent-daemon.log shows error No module named 'apt_pkg'
x
customlogger.py INFO - from pf9app.pf9_app_db import Pf9AppDb as AppDb, Pf9AgentDbcustomlogger.py INFO - File "/opt/pf9/hostagent/lib/python3.9/site-packages/pf9app/pf9_app_db.py", line 21, in <module>customlogger.py INFO - import aptcustomlogger.py INFO - File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>customlogger.py INFO - import apt_pkgcustomlogger.py INFO - ModuleNotFoundErrorcustomlogger.py INFO - :customlogger.py INFO - No module named 'apt_pkg'Environment
- pf9-hostagent
- Python3
Cause
When a newer python version is installed the link will update to point to
the newest python version, which leads to the error of apt_pkg module
not being found.
Resolution
- Make sure package
python3-aptis installed on the host. - Fix the python symblink:
# cd /usr/lib/python3/dist-packages# ln -s apt_pkg.cpython-35m-x86_64-linux-gnu.so apt_pkg.so# ln -s apt_inst.cpython-35m-x86_64-linux-gnu.so apt_inst.so- Restart
pf9-hostagentservice:
# systemctl restart pf9-hostagentWas this page helpful?