Ubuntu – Errors when using apt-get install or remove

apt

I'm very new on Ubuntu but I'm running a VPS (Ubuntu Xenial (16.04)).

When I try to remove or install something, I get alot of errors with Python.

Anyone have a solution?

EDIT: Added the whole log, it's the output for removing the program svtplay-dl.

gel@gel:/var/www/gustavelmgren.me/public_html$ sudo apt-get remove svtplay-dl 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libestr0 libjson-c2 python-cffi-backend python-chardet python-cryptography python-ndg-httpsclient python-openssl python-requests python-urllib3 rtmpdump
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  svtplay-dl
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
14 not fully installed or removed.
After this operation, 75.8 kB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 27718 files and directories currently installed.)
Removing svtplay-dl (0.30.2016.02.08-1) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up python-pkg-resources (20.7.0-1) ...
/var/lib/dpkg/info/python-pkg-resources.postinst: 6: /var/lib/dpkg/info/python-pkg-resources.postinst: pycompile: not found
dpkg: error processing package python-pkg-resources (--configure):
 subprocess installed post-installation script returned error exit status 127
dpkg: dependency problems prevent configuration of python-chardet:
 python-chardet depends on python-pkg-resources; however:
  Package python-pkg-resources is not configured yet.

dpkg: error processing package python-chardet (--configure):
 dependency problems - leaving unconfigured
Setting up python-crypto (2.6.1-6build1) ...
/var/lib/dpkg/info/python-crypto.postinst: 6: /var/lib/dpkg/info/python-crypto.postinst: pycompile: not found
dpkg: error processing package python-crypto (--configure):
 subprocess installed post-installation script returned error exit status 127
Setting up python-enum34 (1.1.2-1) ...
/var/lib/dpkg/info/python-enum34.postinst: 6: /var/lib/dpkg/info/python-enum34.postinst: pycompile: not found
dpkg: error processing package python-enum34 (--configure):
 subprocess installed post-installation script returned error exit status 127
Setting up python-idna (2.0-3) ...
/var/lib/dpkg/info/python-idna.postinst: 6: /var/lib/dpkg/info/python-idna.postinst: pycompile: not found
dpkg: error processing package python-idna (--configure):
 subprocess installed post-installation script returned error exit status 127
Setting up python-ipaddress (1.0.16-1) ...
/var/lib/dpkg/info/python-ipaddress.postinst: 6: /var/lib/dpkg/info/python-ipaddress.postinst: pycompile: not found
dpkg: error processing package python-ipaddress (--configure):
 subprocess installed post-installation script returned error exit status 127
Setting up python-pyasn1 (0.1.9-1) ...
/var/lib/dpkg/info/python-pyasn1.postinst: 6: /var/lib/dpkg/info/python-pyasn1.postinst: pycompile: not found
dpkg: error processing package python-pyasn1 (--configure):
 subprocess installed post-installation script returned error exit status 127
Setting up python-six (1.10.0-3) ...
/var/lib/dpkg/info/python-six.postinst: 6: /var/lib/dpkg/info/python-six.postinst: pycompile: not found
dpkg: error processing package python-six (--configure):
 subprocess installed post-installation script returned error exit status 127
dpkg: dependency problems prevent configuration of python-cryptography:
 python-cryptography depends on python-enum34; however:
  Package python-enum34 is not configured yet.
 python-cryptography depends on python-idna; however:
  Package python-idna is not configured yet.
 python-cryptography depends on python-ipaddress; however:
  Package python-ipaddress is not configured yet.
 python-cryptography depends on python-pkg-resources; however:
  Package python-pkg-resources is not configured yet.
 python-cryptography depends on python-pyasn1 (>= 0.1.8); however:
  Package python-pyasn1 is not configured yet.
 python-cryptography depends on python-six (>= 1.4.1); however:
  Package python-six is not configured yet.

dpkg: error processing package python-cryptography (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-openssl:
 python-openssl depends on python-cryptography (>= 0.7); however:
  Package python-cryptography is not configured yet.
 python-openssl depends on python-six; however:
  Package python-six is not configured yet.

dpkg: error processing package python-openssl (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-ndg-httpsclient:
 python-ndg-httpsclient depends on python-openssl; however:
  Package python-openssl is not configured yet.

dpkg: error processing package python-ndg-httpsclient (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-urllib3:
 python-urllib3 depends on python-six; however:
  Package python-six is not configured yet.

dpkg: error processing package python-urllib3 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-requests:
 python-requests depends on python-urllib3 (>= 1.13.1); however:
  Package python-urllib3 is not configured yet.
 python-requests depends on python-chardet; however:
  Package python-chardet is not configured yet.
 python-requests depends on python-urllib3 (<< 1.13.2); however:
  Package python-urllib3 is not configured yet.

dpkg: error processing package python-requests (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 python-pkg-resources
 python-chardet
 python-crypto
 python-enum34
 python-idna
 python-ipaddress
 python-pyasn1
 python-six
 python-cryptography
 python-openssl
 python-ndg-httpsclient
 python-urllib3
 python-requests
E: Sub-process /usr/bin/dpkg returned an error code (1)

When I run: sudo dpkg --configure -a

dpkg: dependency problems prevent configuration of python-urllib3:
 python-urllib3 depends on python-six; however:
  Package python-six is not configured yet.

dpkg: error processing package python-urllib3 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-chardet:
 python-chardet depends on python-pkg-resources; however:
  Package python-pkg-resources is not configured yet.

dpkg: error processing package python-chardet (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-openssl:
 python-openssl depends on python-six; however:
  Package python-six is not configured yet.

dpkg: error processing package python-openssl (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-cryptography:
 python-cryptography depends on python-enum34; however:
  Package python-enum34 is not configured yet.
 python-cryptography depends on python-idna; however:
  Package python-idna is not configured yet.
 python-cryptography depends on python-ipaddress; however:
  Package python-ipaddress is not configured yet.
 python-cryptography depends on python-pkg-resources; however:
  Package python-pkg-resources is not configured yet.
 python-cryptography depends on python-pyasn1 (>= 0.1.8); however:
  Package python-pyasn1 is not configured yet.
 python-cryptography depends on python-six (>= 1.4.1); however:
  Package python-six is not configured yet.

dpkg: error processing package python-cryptography (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-requests:
 python-requests depends on python-urllib3 (>= 1.13.1); however:
  Package python-urllib3 is not configured yet.
 python-requests depends on python-chardet; however:
  Package python-chardet is not configured yet.
 python-requests depends on python-urllib3 (<< 1.13.2); however:
  Package python-urllib3 is not configured yet.

dpkg: error processing package python-requests (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-ndg-httpsclient:
 python-ndg-httpsclient depends on python-openssl; however:
  Package python-openssl is not configured yet.

dpkg: error processing package python-ndg-httpsclient (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 python-urllib3
 python-chardet
 python-openssl
 python-cryptography
 python-requests
 python-ndg-httpsclient

Best Answer

Run these commands in your terminal:

sudo apt-get --fix-missing --reinstall install python python-minimal dh-python
sudo apt-get -f install

I had a similar problem, and that cleared it up for me.