3

System info: Ubuntu 18.04.4 LTS (GNU/Linux 4.15.0-88-generic x86_64)

When attempting to install or uninstall using apt I'm getting an error:

trever@server:~$ sudo apt-get install ctorrent
[sudo] password for trever: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 python-pkg-resources : Depends: python:any (< 2.8)
                        Depends: python:any (>= 2.7.5-5~)
 python-virtualenv : Depends: python but it is not going to be installed
                     Recommends: virtualenv but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

When I try to run the command it suggests, I get another error, and I just go in circles with the dependencies:

trever@server:~$ sudo apt --fix-broken install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
  python
Suggested packages:
  python-doc python-tk
The following NEW packages will be installed:
  python
0 upgraded, 1 newly installed, 0 to remove and 27 not upgraded.
7 not fully installed or removed.
Need to get 0 B/140 kB of archives.
After this operation, 639 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up python2.7-minimal (2.7.17-1~18.04) ...
Could not find platform independent libraries <prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
/usr/bin/python2.7: can't open file '/usr/lib/python2.7/py_compile.py': [Errno 2] No such file or directory
dpkg: error processing package python2.7-minimal (--configure):
 installed python2.7-minimal package post-installation script subprocess returned error exit status 2
dpkg: dependency problems prevent configuration of python-minimal:
 python-minimal depends on python2.7-minimal (>= 2.7.15~rc1-1~); however:
  Package python2.7-minimal is not configured yet.

dpkg: error processing package python-minimal (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 python2.7-minimal
 python-minimal
E: Sub-process /usr/bin/dpkg returned an error code (1)

How can I fix this? Something in my Python is royally jacked up and now its affecting other parts of the system too..

EDIT:

trever@server:/usr/lib$ sudo dpkg --configure -a
Setting up python3.8 (3.8.2-1+bionic1) ...
Could not find platform independent libraries <prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Python path configuration:
  PYTHONHOME = (not set)
  PYTHONPATH = (not set)
  program name = '/usr/bin/python3.8'
  isolated = 0
  environment = 0
  user site = 1
  import site = 0
  sys._base_executable = '/usr/bin/python3.8'
  sys.base_prefix = '/usr'
  sys.base_exec_prefix = '/usr'
  sys.executable = '/usr/bin/python3.8'
  sys.prefix = '/usr'
  sys.exec_prefix = '/usr'
  sys.path = [
    '/usr/lib/python38.zip',
    '/usr/lib/python3.8',
    '/usr/lib/python3.8/lib-dynload',
  ]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007f498c8b3740 (most recent call first):
<no Python frame>
dpkg: error processing package python3.8 (--configure):
 installed python3.8 package post-installation script subprocess returned error exit status 1
Setting up python3-virtualenv (15.1.0+ds-1.1) ...
[Errno 2] No such file or directory: '/usr/lib/python3/dist-packages/virtualenv.py'
dpkg: error processing package python3-virtualenv (--configure):
 installed python3-virtualenv package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 python3.8
 python3-virtualenv
1

If you have not upgraded your system with sudo apt-get upgrade, do so. Then, I suggest that you try to install your files. Also, if sudo apt-get upgrade does not work, use sudo dpkg --configure -a and try again. Make sure to do the upgrade command after you configure dpkg. Then you should be able to install the files. If none of these work, try some of the things on this website: iasptk.com/ubuntu-fix-broken-package-best-solution

It has possible solutions.

| improve this answer | |
  • Thanks for the suggestion, but that didn't do anything. I did the upgrade and then the configure and I get the appended error message. – trever Mar 6 at 21:07
  • I will do some research. I will get back to you soon. – Jeff Mar 6 at 21:09
  • Thank you! I have spent hours and hours on this and can't figure it out. The best I've done is copy from a backup the /usr/lib/python* files and that has partially resolved the issue where I can do the apt upgrade but still having this error. – trever Mar 6 at 21:11
  • Here is a list of possible solutions: iasptk.com/ubuntu-fix-broken-package-best-solution I hope it is helpful. – Jeff Mar 6 at 21:14
  • THIS WORKED. THANK YOU – trever Mar 6 at 21:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.