Skip to content

Instantly share code, notes, and snippets.

@aspen-roller
Created December 7, 2020 21:25
Show Gist options
  • Save aspen-roller/85ff3ea8319f305054730ee44b29142c to your computer and use it in GitHub Desktop.
Save aspen-roller/85ff3ea8319f305054730ee44b29142c to your computer and use it in GitHub Desktop.
fix could not import python modules: apt apt_pkg #debug #python
# This was done in Ubunut-20.04
# I've observed this in other Ubuntu releases when Python gets updated
# https://github.com/ansible/ansible/issues/14468#issuecomment-459630445
cd /tmp
# download and unarchive python3-apt
apt-get download python3-apt
dpkg -x python3-apt_2.0.0ubuntu0.20.04.1_amd64.deb python3-apt
# copy packages
cp -r python3-apt/usr/lib/python3/dist-packages/* ~/python-env/ansible-2.9/lib/python3.8/site-packages/
# rename pacakges
cd ~/python-env/ansible-2.9/lib/python3.8/site-packages/
mv apt_inst.cpython-38-x86_64-linux-gnu.so apt_inst.so
mv apt_pkg.cpython-38-x86_64-linux-gnu.so apt_pkg.so
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment