Errors when attempting to unpack python-pkg-resources_44.1.1-1_all.deb

Cherry_Sec

New Member
Credits
97
I am running a kai linux 2020.1 64 bit VM. when I run sudo apt upgrade I get the following errors:
Code:
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
  php-common python-cffi-backend python3-django python3-dnspython python3-tables-lib
The following packages will be upgraded:
  python-pkg-resources
1 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.
166 not fully installed or removed.
Need to get 0 B/182 kB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 301734 files and directories currently installed.)
Preparing to unpack .../python-pkg-resources_44.1.1-1_all.deb ...
ERROR: unknown command "/usr/bin/pyclean"
dpkg: warning: old python-pkg-resources package pre-removal script subprocess returned error exit status 1
dpkg: trying script from the new package instead ...
ERROR: unknown command "/usr/bin/pyclean"
dpkg: error processing archive /var/cache/apt/archives/python-pkg-resources_44.1.1-1_all.deb (--unpack):
 new python-pkg-resources package pre-removal script subprocess returned error exit status 1
ERROR: unknown command "/usr/bin/pycompile"
dpkg: error while cleaning up:
 installed python-pkg-resources package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 /var/cache/apt/archives/python-pkg-resources_44.1.1-1_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
I have checked that both pycompile and pyclean are in the /usr/bin directory. when I tried manually unpack the file with sudo gdebi python-pkg-resources_44.1.1-1_all.deb I got similar errors:
Code:
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Reading state information... Done
Requires the installation of the following packages: python-pkg-resources

Package Discovery and Resource Access using pkg_resources
 The pkg_resources module provides an API for Python libraries to                                                                                                                                           
 access their resource files, and for extensible applications and                                                                                                                                           
 frameworks to automatically discover plugins.  It also provides                                                                                                                                             
 runtime support for using C extensions that are inside zipfile-format                                                                                                                                       
 eggs, support for merging packages that have separately-distributed                                                                                                                                         
 modules or subpackages, and APIs for managing Python's current                                                                                                                                             
 "working set" of active packages.                                                                                                                                                                           
Do you want to install the software package? [y/N]:y                                                                                                                                                         
/usr/bin/gdebi:113: FutureWarning: Possible nested set at position 1                                                                                                                                         
  c = findall("[[(](\S+)/\S+[])]", msg)[0].lower()                                                                                                                                                           
Fetched 0 B in 0s (0 B/s)                                                                                                                                                                                   
(Reading database ... 301734 files and directories currently installed.)                                                                                                                                     
Preparing to unpack .../python-pkg-resources_44.1.1-1_all.deb ...                                                                                                                                           
ERROR: unknown command "/usr/bin/pyclean"                                                                                                                                                                   
dpkg: warning: old python-pkg-resources package pre-removal script subprocess returned error exit status 1                                                                                                   
dpkg: trying script from the new package instead ...                                                                                                                                                         
ERROR: unknown command "/usr/bin/pyclean"                                                                                                                                                                   
dpkg: error processing archive /var/cache/apt/archives/python-pkg-resources_44.1.1-1_all.deb (--unpack):                                                                                                     
 new python-pkg-resources package pre-removal script subprocess returned error exit status 1                                                                                                                 
ERROR: unknown command "/usr/bin/pycompile"
dpkg: error while cleaning up:
 installed python-pkg-resources package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 /var/cache/apt/archives/python-pkg-resources_44.1.1-1_all.deb
E:Sub-process /usr/bin/dpkg returned an error code (1)
Error during install: 'installArchives() failed'
I have looked around and haven't been able to find a fix for this problem, any help would be appreciated!
 


f33dm3bits

Gold Member
Gold Supporter
Credits
7,568
How did you check to see if the commands are installed?
Try:
Code:
which pyclean
which pycompile
If you don't get any file location of the binary in return install the package dh-python.
 

Cherry_Sec

New Member
Credits
97
running those commands i got
/usr/local/bin/pyclean
and
/usr/local/bin/pycompile
When I said I have checked they are in the /usr/bin I meant that when I ran /usr/bin$ ls | grep -i pyc both of the python files pycompile and pyclean were present.
 

f33dm3bits

Gold Member
Gold Supporter
Credits
7,568
You weren't giving much information to start with, it seems the apt-get is looking for them in /usr/bin when trying to update. You can try symlinking both packages from /usr/local/bin to /usr/bin. If that doesn't work remove the symlinks and install the package that provides the binaries in the location apt-get update is expecting them to be, dh-python.
 

Cherry_Sec

New Member
Credits
97
I moved the pycompile and pyclean files out of /usr/bin in order to create a symlink for both of them pointing to usr/local/bin. this however did not fix the issue and i was still getting the same errors. So after removing the symlinks i installed the dh-python package with sudo apt-get install dh-python which gave me:
Code:
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  dh-python
0 upgraded, 1 newly installed, 0 to remove and 13 not upgraded.
5 not fully installed or removed.
Need to get 0 B/273 kB of archives.
After this operation, 413 kB of additional disk space will be used.
Selecting previously unselected package dh-python.
(Reading database ... 301742 files and directories currently installed.)
Preparing to unpack .../dh-python_4.20200315_all.deb ...
Unpacking dh-python (4.20200315) ...
Setting up dh-python (4.20200315) ...
Setting up python-support (1.0.15) ...
ERROR: unknown command "/usr/sbin/update-python-modules"
dpkg: error processing package python-support (--configure):
 installed python-support package post-installation script subprocess returned error exit status 1
dpkg: error processing package python-pkg-resources (--configure):
 package is in a very bad inconsistent state; you should
 reinstall it before attempting configuration
dpkg: dependency problems prevent configuration of python-lzma:
 python-lzma depends on python-support (>= 0.90.0); however:
  Package python-support is not configured yet.

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

dpkg: error processing package yum (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-urlgrabber:
 python-urlgrabber depends on python-support (>= 0.90.0); however:
  Package python-support is not configured yet.

dpkg: error processing package python-urlgrabber (--configure):
 dependency problems - leaving unconfigured
Processing triggers for man-db (2.9.3-2) ...
Processing triggers for kali-menu (2020.3.2) ...
Errors were encountered while processing:
 python-support
 python-pkg-resources
 python-lzma
 yum
 python-urlgrabber
needrestart is being skipped since dpkg has failed
E: Sub-process /usr/bin/dpkg returned an error code (1)
And trying sudo apt-get upgrade now gives:
Code:
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
  gstreamer1.0-plugins-ugly gvfs gvfs-backends gvfs-daemons gvfs-fuse gvfs-libs libcdio-cdda2 libcdio-paranoia2 php-common python-cffi-backend python3-django python3-dnspython python3-tables-lib
0 upgraded, 0 newly installed, 0 to remove and 13 not upgraded.
5 not fully installed or removed.
Need to get 0 B/182 kB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up python-support (1.0.15) ...
ERROR: unknown command "/usr/sbin/update-python-modules"
dpkg: error processing package python-support (--configure):
 installed python-support package post-installation script subprocess returned error exit status 1
dpkg: error processing package python-pkg-resources (--configure):
 package is in a very bad inconsistent state; you should
 reinstall it before attempting configuration
dpkg: dependency problems prevent configuration of python-lzma:
 python-lzma depends on python-support (>= 0.90.0); however:
  Package python-support is not configured yet.

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

dpkg: error processing package yum (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-urlgrabber:
 python-urlgrabber depends on python-support (>= 0.90.0); however:
  Package python-support is not configured yet.

dpkg: error processing package python-urlgrabber (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 python-support
 python-pkg-resources                                                                                                                                                                                       
 python-lzma                                                                                                                                                                                                 
 yum                                                                                                                                                                                                         
 python-urlgrabber                                                                                                                                                                                           
needrestart is being skipped since dpkg has failed                                                                                                                                                           
E: Sub-process /usr/bin/dpkg returned an error code (1)
These don't seem to be processing the python-pkg-resources_44.1.1-1_all.deb file, so I tried the sudo gdebi python-pkg-resources_44.1.1-1_all.deb again and this time got:
Code:
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Reading state information... Done

Package Discovery and Resource Access using pkg_resources
 The pkg_resources module provides an API for Python libraries to
 access their resource files, and for extensible applications and
 frameworks to automatically discover plugins.  It also provides
 runtime support for using C extensions that are inside zipfile-format
 eggs, support for merging packages that have separately-distributed
 modules or subpackages, and APIs for managing Python's current
 "working set" of active packages.
Do you want to install the software package? [y/N]:y
/usr/bin/gdebi:113: FutureWarning: Possible nested set at position 1
  c = findall("[[(](\S+)/\S+[])]", msg)[0].lower()
(Reading database ... 301788 files and directories currently installed.)
Preparing to unpack python-pkg-resources_44.1.1-1_all.deb ...
ERROR: unknown command "/usr/local/bin/pyclean"
dpkg: warning: old python-pkg-resources package pre-removal script subprocess returned error exit status 1
dpkg: trying script from the new package instead ...
ERROR: unknown command "/usr/local/bin/pyclean"
dpkg: error processing archive python-pkg-resources_44.1.1-1_all.deb (--install):
 new python-pkg-resources package pre-removal script subprocess returned error exit status 1
ERROR: unknown command "/usr/local/bin/pycompile"
dpkg: error while cleaning up:
 installed python-pkg-resources package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 python-pkg-resources_44.1.1-1_all.deb
After reading this similar error and reading the comments in the pycompile and pyclean python files i believe the problem might be with the default version of python on my machine. python --version gives pip 20.2 from /home/cherry/.local/lib/python3.8/site-packages/pip (python 3.8) Should i try to change the default version of python to a python 2 version or is there some workaround that i could use to avoid that?
 

f33dm3bits

Gold Member
Gold Supporter
Credits
7,568
I just installed Kali in a vm, looks like both commands come from a different package under Kali.
Try reinstalling instead of installing the package:
Code:
sudo apt-get reinstall python2-minimal
Also it seems for me the default python version is 2.7.18 in Kali. Did you compile install pycompile and pyclean by using pip3 before, since they were installed under /usr/local/bin?
 
Last edited:

Cherry_Sec

New Member
Credits
97
I reinstalled the python2-minimal package but the error still persists, and 3.8 is still my default python version. I didn't use pip3 to install pycompile or pyclean, I think i just might have copied them over to /usr/local/bin at some point during trying to fix these errors. I remember when i was trying to install pip that I used the get-pip.py script (info here) as i was getting errors when trying to install it using apt. However, as it said on the linked page using this when python is installed via the operating system (like in the case of python 2.7.18 in kali) can cause problems, and I know think that I might be suffering from the inconsitent state that it warned about, although I am not certain about that. Any ideas?
 

f33dm3bits

Gold Member
Gold Supporter
Credits
7,568
You can try setting the default python version back to 2.7.18 by using update-alternatives(scroll down section where it talks about that).
 

Cherry_Sec

New Member
Credits
97
I followed the instructions and update-alternatives --config python even returned update-alternatives: using /usr/bin/python2.7 to provide /usr/bin/python (python) in manual mode, However, the python version is still pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8). Just in case i checked to see if anything changed in either sudo gdebi python-pkg-resources_44.1.1-1_all.deb or sudo apt-get upgrade but both are still returning the same errors as before. Would there be a way for me to just remove pip and reinstall it later without using get-pip.py?
 

f33dm3bits

Gold Member
Gold Supporter
Credits
7,568
Try: update-alternatives --remove python /usr/bin/python3

The safe way to install pip is by installing it from the repositories: apt-get install python-pip. Did you only run that script with your own user account? You can try delete the directory: /home/cherry/.local/lib/python3.8.
 
Last edited:

Cherry_Sec

New Member
Credits
97
I've tried that but it didn't seem to make a difference to anything, The errors are still there when I try sudo apt-get upgrade and sudo gdebi python-pkg-resources_44.1.1-1_all.deb, and the python version is still pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)
 

f33dm3bits

Gold Member
Gold Supporter
Credits
7,568
I've tried that but it didn't seem to make a difference to anything, The errors are still there when I try sudo apt-get upgrade and sudo gdebi python-pkg-resources_44.1.1-1_all.deb, and the python version is still pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)
How did you install python3.8 or was it also installed after you installed ran that get-pip.py script?
 

f33dm3bits

Gold Member
Gold Supporter
Credits
7,568
Can you list the python 3.8 packages you actually through the package manager?
dpkg --list | grep python3.8

Also what are you getting when you run: update-alternatives --list python
 

Cherry_Sec

New Member
Credits
97
dpkg --list | grep python3.8 gives:
Code:
ii  libpython3.8:amd64                   3.8.5-2                         amd64        Shared Python runtime library (version 3.8)
ii  libpython3.8-dev:amd64               3.8.5-2                         amd64        Header files and a static library for Python (v3.8)
ii  libpython3.8-minimal:amd64           3.8.5-2                         amd64        Minimal subset of the Python language (version 3.8)
ii  libpython3.8-stdlib:amd64            3.8.5-2                         amd64        Interactive high-level object-oriented language (standard library, version 3.8)
ii  python3.8                            3.8.5-2                         amd64        Interactive high-level object-oriented language (version 3.8)
ii  python3.8-dev                        3.8.5-2                         amd64        Header files and a static library for Python (v3.8)
ii  python3.8-minimal                    3.8.5-2                         amd64        Minimal subset of the Python language (version 3.8)
And update-alternatives --list python just gives:
/usr/bin/python2.7
/usr/bin/python3.8
 

Cherry_Sec

New Member
Credits
97
Also, I don't know if this is of any use but i found that running python --version at some point executes the python file /usr/bin/python, which contains the following:
Code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from pip._internal.cli.main import main
if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(main())
When I removed the pip folders from /.local/lib/python3.8/site-packages and /usr/lib/python3/dist-packages running python --version gave the error:
Code:
Traceback (most recent call last):
  File "/usr/bin/python", line 5, in <module>
    from pip._internal.cli.main import main
ModuleNotFoundError: No module named 'pip'
(I have sinced returned the pip folders to their original locations ). This would suggest to me that the reason the default python did not change after running update-alternatives --config python was because of this python file, although im honestly not sure.
 

f33dm3bits

Gold Member
Gold Supporter
Credits
7,568
Yes if /usr/bin/python is a file beginning with: #!/usr/bin/python3 that means it will always execute it with python3. That explains why update-alternatives didn't do anything, I would expect it to be a binary. Try moving that file /usr/bin/python to a backup location in your homedir. Then reinstall the default python: apt-get reinstall python, then see if that /usr/bin/python file is a binary now.
 

Cherry_Sec

New Member
Credits
97
Running apt-get reinstall python just gives me:
Code:
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 13 not upgraded.
6 not fully installed or removed.
Need to get 22.9 kB/205 kB of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 http://kali.download/kali kali-rolling/main amd64 python amd64 2.7.17-2 [22.9 kB]
Fetched 22.9 kB in 1s (17.4 kB/s)
(Reading database ... 301788 files and directories currently installed.)
Preparing to unpack .../python_2.7.17-2_amd64.deb ...
update-alternatives: warning: forcing reinstallation of alternative /usr/bin/python2.7 because link group python is broken
Unpacking python (2.7.17-2) over (2.7.17-2) ...
dpkg: error processing package python-pkg-resources (--configure):
 package is in a very bad inconsistent state; you should
 reinstall it before attempting configuration
Setting up python2-minimal (2.7.17-2) ...

Usage:   
  python2.7 <command> [options]

no such option: -m
dpkg: error processing package python2-minimal (--configure):
 installed python2-minimal package post-installation script subprocess returned error exit status 2
Setting up python (2.7.17-2) ...
Setting up python-support (1.0.15) ...
ERROR: unknown command "/usr/sbin/update-python-modules"
dpkg: error processing package python-support (--configure):
 installed python-support package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of python-lzma:
 python-lzma depends on python-support (>= 0.90.0); however:
  Package python-support is not configured yet.

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

dpkg: error processing package yum (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-urlgrabber:
 python-urlgrabber depends on python-support (>= 0.90.0); however:
  Package python-support is not configured yet.

dpkg: error processing package python-urlgrabber (--configure):
 dependency problems - leaving unconfigured
Processing triggers for man-db (2.9.3-2) ...
Processing triggers for kali-menu (2020.3.2) ...
Errors were encountered while processing:
 python-pkg-resources
 python2-minimal
 python-support
 python-lzma
 yum
 python-urlgrabber
needrestart is being skipped since dpkg has failed
E: Sub-process /usr/bin/dpkg returned an error code (1)
And the new /usr/bin/python file is as it was before I moved and reinstalled it.
I noticed in this error it says
Code:
dpkg: error processing package python-pkg-resources (--configure):
 package is in a very bad inconsistent state; you should
 reinstall it before attempting configuration
Should I try apt-get reinstall python-pkg-resources?
 

f33dm3bits

Gold Member
Gold Supporter
Credits
7,568
Yes start with that: apt-get reinstall python-pkg-resources
 

Cherry_Sec

New Member
Credits
97
When i run apt-get reinstall python-pkg-resources i get the familiar error:
Code:
Reading package lists... Done
Building dependency tree      
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 13 not upgraded.
6 not fully installed or removed.
Need to get 0 B/182 kB of archives.
After this operation, 0 B of additional disk space will be used.
(Reading database ... 301788 files and directories currently installed.)
Preparing to unpack .../python-pkg-resources_44.1.1-1_all.deb ...
ERROR: unknown command "/usr/bin/pyclean"
dpkg: warning: old python-pkg-resources package pre-removal script subprocess returned error exit status 1
dpkg: trying script from the new package instead ...
ERROR: unknown command "/usr/bin/pyclean"
dpkg: error processing archive /var/cache/apt/archives/python-pkg-resources_44.1.1-1_all.deb (--unpack):
new python-pkg-resources package pre-removal script subprocess returned error exit status 1
ERROR: unknown command "/usr/bin/pycompile"
dpkg: error while cleaning up:
installed python-pkg-resources package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
/var/cache/apt/archives/python-pkg-resources_44.1.1-1_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
And running apt-get reinstall python again gave the same error as before so it reinstalling didn't seem to do anything because of that python-pkg-resources_44.1.1-1_all.deb again, so now i'm a bit lost for ideas.
 


Members online


Top