I have a problem with a Debian server that I use for multiple purposes.
Yesterday I tried to upgrade my packages with a simple
apt-get update / upgrade as usual and found everything to be broken :
Reading package lists... Done Building dependency tree Reading state information... Done Calculating upgrade... Done The following packages have been kept back: owncloud owncloud-config-apache owncloud-server The following packages will be upgraded: python-apt 1 upgraded, 0 newly installed, 0 to remove and 3 not upgraded. 2 not fully installed or removed. Need to get 0 B/171 kB of archives. After this operation, 47.1 kB disk space will be freed. Do you want to continue? [Y/n] perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = (unset), LC_ALL = (unset), LC_CTYPE = "UTF-8", LANG = "en_US.UTF-8" are supported and installed on your system. perl: warning: Falling back to a fallback locale ("en_US.UTF-8"). locale: Cannot set LC_CTYPE to default locale: No such file or directory locale: Cannot set LC_ALL to default locale: No such file or directory (Reading database ... 83301 files and directories currently installed.) Preparing to unpack .../python-apt_0.9.3.12_amd64.deb ... /var/lib/dpkg/info/python-apt.prerm: /usr/bin/pyclean: /usr/bin/python: bad interpreter: No such file or directory dpkg: warning: subprocess old pre-removal script returned error exit status 126 dpkg: trying script from the new package instead ... /var/lib/dpkg/tmp.ci/prerm: /usr/bin/pyclean: /usr/bin/python: bad interpreter: No such file or directory dpkg: error processing archive /var/cache/apt/archives/python-apt_0.9.3.12_amd64.deb (--unpack): subprocess new pre-removal script returned error exit status 126 /var/lib/dpkg/info/python-apt.postinst: /usr/bin/pycompile: /usr/bin/python: bad interpreter: No such file or directory dpkg: error while cleaning up: subprocess installed post-installation script returned error exit status 126 Errors were encountered while processing: /var/cache/apt/archives/python-apt_0.9.3.12_amd64.deb E: Sub-process /usr/bin/dpkg returned an error code (1)
Since then I've tried applying a bunch of solutions including the recommendations of a
dpkg --audit as well as suggested solutions here and on other community help websites for similar issues, to no avail.
It also appears that even after fixing the locale issue that perl mentions, it reappears if I quit my ssh session and open a new one.
Any ideas how I can fix this ? (besides reinstalling from scratch which I'd rather avoid if possible.)
EDIT (updated): As per requested by @Gilles, here is the result of
ls -l /usr/bin/python; ls -lL /usr/bin/python; dpkg -S /usr/bin/python
ls: cannot access /usr/bin/python: No such file or directory ls: cannot access /usr/bin/python: No such file or directory python-minimal: /usr/bin/python
I have no recollection of ever changing python settings manually.