I'll start with some details of what led up to this:
- I'm using Ubuntu 14.0 (KDE on top although presumably that's irrelevant)
- a few days ago I let the system do an auto-upgrade.
- It crashed partway through when trying to update Virtualbox, which I assumed to be due to my having it up and running at the time. (I don't have the error it gave)
- I shrugged that off with a "piss on it, I'll deal with it later".
- Today we had a power outage, and when I try to re-start any of my virtual machines, I instead get an error. Sadly, I do not have that error. I believe the package is now thoroughly broken in my attempts to fix it. I can't even find the program, much less run it.
I'm now however having problems just fixing or even removing the package. For brevity, I'm not going to include the full console output here - just the errors. I can certainly add more if needed.
So first, I did an apt-get upgrade, and got this:
You might want to run 'apt-get -f install' to correct these.
The following packages have unmet dependencies: virtualbox-dkms : Depends: virtualbox (>= 4.3.18-dfsg-2ubuntu1) but 4.3.18-dfsg-1 is installed virtualbox-qt : Depends: virtualbox (= 4.3.18-dfsg-2ubuntu1) but 4.3.18-dfsg-1 is installedAs per the recommendation output by apt-get, I did this:
apt-get -f installAnd got:
Correcting dependencies... Done
The following packages were automatically installed and are no longer required: linux-headers-3.16.0-23 linux-headers-3.16.0-23-generic linux-image-3.16.0-23-generic linux-image-extra-3.16.0-23-generic
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed: virtualbox
Suggested packages: vde2 virtualbox-guest-additions-iso
The following packages will be upgraded: virtualbox
...
Preparing to unpack .../virtualbox_4.3.18-dfsg-2ubuntu1_amd64.deb ... File "/usr/bin/pyclean", line 63 except (IOError, OSError), e: ^
SyntaxError: invalid syntax
dpkg: warning: subprocess old pre-removal script returned error exit status 1
dpkg: trying script from the new package instead ... File "/usr/bin/pyclean", line 63 except (IOError, OSError), e: ^
SyntaxError: invalid syntax
dpkg: error processing archive /var/cache/apt/archives/virtualbox_4.3.18-dfsg-2ubuntu1_amd64.deb (--unpack): subprocess new pre-removal script returned error exit status 1
Traceback (most recent call last): File "/usr/bin/pycompile", line 35, in <module> from debpython.version import SUPPORTED, debsorted, vrepr, \ File "/usr/share/python/debpython/version.py", line 24, in <module> from ConfigParser import SafeConfigParser
ImportError: No module named 'ConfigParser'
dpkg: error while cleaning up: subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing: /var/cache/apt/archives/virtualbox_4.3.18-dfsg-2ubuntu1_amd64.debNow, I'm not a Python guy, but thought I'd at least take a shot at seeing if I could fix those syntax errors by moving the ", e" within the parentheses on those lines. When I changed the one noted above, I got the same error on a line in /usr/share/python/debpython/namespace.py. I changed that too and then got this error:
root@gonzo:~# apt-get -f remove
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required: dkms linux-headers-3.16.0-23 linux-headers-3.16.0-23-generic linux-image-3.16.0-23-generic linux-image-extra-3.16.0-23-generic virtualbox-dkms
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed: virtualbox
Suggested packages: vde2 virtualbox-guest-additions-iso
The following packages will be upgraded: virtualbox
1 upgraded, 0 newly installed, 0 to remove and 98 not upgraded.
129 not fully installed or removed.
Need to get 0 B/15.9 MB of archives.
After this operation, 17.4 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 209565 files and directories currently installed.)
Preparing to unpack .../virtualbox_4.3.18-dfsg-2ubuntu2_amd64.deb ...
Traceback (most recent call last): File "/usr/bin/pyclean", line 32, in <module> from debpython.namespace import add_namespace_files File "/usr/share/python/debpython/namespace.py", line 28, in <module> from debpython.pydist import PUBLIC_DIR_RE File "/usr/share/python/debpython/pydist.py", line 27, in <module> from string import maketrans
ImportError: cannot import name 'maketrans'
dpkg: warning: subprocess old pre-removal script returned error exit status 1
dpkg: trying script from the new package instead ...
Traceback (most recent call last): File "/usr/bin/pyclean", line 32, in <module> from debpython.namespace import add_namespace_files File "/usr/share/python/debpython/namespace.py", line 28, in <module> from debpython.pydist import PUBLIC_DIR_RE File "/usr/share/python/debpython/pydist.py", line 27, in <module> from string import maketrans
ImportError: cannot import name 'maketrans'
dpkg: error processing archive /var/cache/apt/archives/virtualbox_4.3.18-dfsg-2ubuntu2_amd64.deb (--unpack): subprocess new pre-removal script returned error exit status 1
Traceback (most recent call last): File "/usr/bin/pycompile", line 35, in <module> from debpython.version import SUPPORTED, debsorted, vrepr, \ File "/usr/share/python/debpython/version.py", line 24, in <module> from ConfigParser import SafeConfigParser
ImportError: No module named 'ConfigParser'
dpkg: error while cleaning up: subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing: /var/cache/apt/archives/virtualbox_4.3.18-dfsg-2ubuntu2_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)At which point I gave figured I was going down the wrong path and reverted my changes on the aforementioned files.
I then (really not knowing what I was doing at that point, and guessing as to how things work), tried moving /var/cache/apt/virtualbox* into another directory and running it again. That of course did not work, so I moved those back.
So I pulled up Synaptic to try fixing it from there. That didn't work either. If I mark the package for removal, I get this error
E: virtualbox: package is in a very bad inconsistent state; you should reinstall it before attempting a removalI can't follow those instructions though, as the "Mark for Reinstallation" option is greyed out.
The entire console output from what Synaptic tried is as follows:
(synaptic:21937): GLib-CRITICAL **: g_child_watch_add_full: assertion 'pid > 0' failed
dpkg: error processing package virtualbox (--purge): package is in a very bad inconsistent state; you should reinstall it before attempting a removal
Errors were encountered while processing: virtualbox
E: Sub-process /usr/bin/dpkg returned an error code (1)
A package failed to install. Trying to recover:And at this point I'm at a total loss. Could anyone lead me out of this?
1 Answer
Ok, so anyone else who happens to come by this issue, my boss managed to figure it out:
I had the wrong version Python running. After switching back from Python 3.4 to Python 2.7.8, the problem was fixed.