Ubuntu – Can’t use pip3 on Ubuntu 14.04

14.04aptpippython3

i have pip and python2.7 installed on Ubuntu and they work perfectly. i have python3.6 installed. whenever i try to use pip3, i get the error:

Traceback (most recent call last):
  File "/usr/bin/pip3", line 5, in <module>
    from pkg_resources import load_entry_point
ModuleNotFoundError: No module named 'pkg_resources'

and whenever i run:

sudo apt-get install python3-pip

i get the errors:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
python3-pip is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 17 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up python3 (3.4.0-0ubuntu2) ...
running python rtupdate hooks for python3.4...
E: py3compile:243: Requested versions are not installed
error running python rtupdate hook dh-python
E: py3compile:243: Requested versions are not installed
error running python rtupdate hook gdebi-core
E: py3compile:243: Requested versions are not installed
error running python rtupdate hook gdebi
E: py3compile:243: Requested versions are not installed
error running python rtupdate hook ibus
E: py3compile:243: Requested versions are not installed
error running python rtupdate hook onboard
E: py3compile:243: Requested versions are not installed
error running python rtupdate hook python3-uno
E: py3compile:243: Requested versions are not installed
error running python rtupdate hook rhythmbox-plugin-magnatune
E: py3compile:243: Requested versions are not installed
error running python rtupdate hook rhythmbox-plugin-zeitgeist
E: py3compile:243: Requested versions are not installed
error running python rtupdate hook rhythmbox-plugins
E: py3compile:243: Requested versions are not installed
error running python rtupdate hook rhythmbox
E: py3compile:243: Requested versions are not installed
error running python rtupdate hook ubuntu-drivers-common
dpkg: error processing package python3 (--configure):
 subprocess installed post-installation script returned error exit status 4
dpkg: dependency problems prevent configuration of python3-pip:
 python3-pip depends on python3:any (>= 3.3.2-2~); however:
  Package python3 is not configured yet.
 python3-pip depends on python3; however:
  Package python3 is not configured yet.

dpkg: error processing package python3-pip (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
                          Errors were encountered while processing:
 python3
 python3-pip
E: Sub-process /usr/bin/dpkg returned an error code (1)

please i really need help.
thank you!

after running sudo apt-get install --reinstall python3-pkg-resources python3-minimal
i got errors… here's the output;

Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 2 reinstalled, 0 to remove and 17 not upgraded.
2 not fully installed or removed.
Need to get 54.9 kB of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 http://ng.archive.ubuntu.com/ubuntu/ trusty/main python3-minimal amd64 3.4.0-0ubuntu2 [23.2 kB]
Get:2 http://ng.archive.ubuntu.com/ubuntu/ trusty-updates/main python3-pkg-resources all 3.3-1ubuntu2 [31.7 kB]
Fetched 54.9 kB in 2s (25.7 kB/s)                
(Reading database ... 246854 files and directories currently installed.)
Preparing to unpack .../python3-minimal_3.4.0-0ubuntu2_amd64.deb ...
Unpacking python3-minimal (3.4.0-0ubuntu2) over (3.4.0-0ubuntu2) ...
Preparing to unpack .../python3-pkg-resources_3.3-1ubuntu2_all.deb ...
/var/lib/dpkg/info/python3-pkg-resources.prerm: 6: /var/lib/dpkg/info/python3-pkg-resources.prerm: py3clean: not found
dpkg: warning: subprocess old pre-removal script returned error exit status 127
dpkg: trying script from the new package instead ...
/var/lib/dpkg/tmp.ci/prerm: 6: /var/lib/dpkg/tmp.ci/prerm: py3clean: not found
dpkg: error processing archive /var/cache/apt/archives/python3-pkg-resources_3.3-1ubuntu2_all.deb (--unpack):
 subprocess new pre-removal script returned error exit status 127
/var/lib/dpkg/info/python3-pkg-resources.postinst: 6: /var/lib/dpkg/info/python3-pkg-resources.postinst: py3compile: not found
dpkg: error while cleaning up:
 subprocess installed post-installation script returned error exit status 127
Processing triggers for man-db (2.7.0.2-2) ...
Errors were encountered while processing:
 /var/cache/apt/archives/python3-pkg-resources_3.3-1ubuntu2_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

Now… i'm really confused.
anytime i try to install anything, it gives errors. Errors like:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Reinstallation of dh-python is not possible, it cannot be downloaded.
0 upgraded, 0 newly installed, 0 to remove and 17 not upgraded.
4 not fully installed or removed.
Need to get 0 B/31.7 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 python3-minimal (3.4.0-0ubuntu2) ...
/var/lib/dpkg/info/python3-minimal.postinst: 5: /var/lib/dpkg/info/python3-minimal.postinst: py3compile: not found
dpkg: error processing package python3-minimal (--configure):
 subprocess installed post-installation script returned error exit status 127
dpkg: dependency problems prevent configuration of python3:
 python3 depends on python3-minimal (= 3.4.0-0ubuntu2); however:
  Package python3-minimal is not configured yet.

dpkg: error processing package python3 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python3-pkg-resources:
 python3-pkg-resources depends on python3:any (>= 3.4); however:
  Package python3 is not configured yet.
 python3-pkg-resources depends on python3:any (<< 3.5); however:
  Package python3 is not configured yet.

dpkg: error processing package python3-pkg-resources (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python3-pip:
 python3-pip depends on python3-pkg-resources; however:
  Package python3-pkg-resources is not configured yet.
 python3-pip depends on python3:any (>= 3.3.2-2~); however:
  Package python3 is not configured yet.
 python3-pip depends on python3; however:
  Package pythNo apport report written because the error message indicates its a followup error from a previous failure.
                                        No apport report written because the error message indicates its a followup error from a previous failure.
                                                                  No apport report written because MaxReports is reached already
                                                on3 is not configured yet.

dpkg: error processing package python3-pip (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 python3-minimal
 python3
 python3-pkg-resources
 python3-pip
E: Sub-process /usr/bin/dpkg returned an error code (1)

Best Answer

  • During chat session we have determined that py3compile and py3clean were broken because of broken symbolic link between python3 and python3.4:

    $ file /usr/bin/python3
    /usr/bin/python3: broken symbolic link to `python3.4'
    

    So we need to reinstall Python 3 packages:

    sudo apt-get install --reinstall libpython3.4 python3.4 python3-gdbm libpython3.4-stdlib libpython3.4-dev libpython3.4-minimal
    

    And finally reinstall all other stuff related to pkg_resources, py3compile and py3clean:

    sudo apt-get install --reinstall python3-pkg-resources python3-minimal 
    sudo apt-get install --reinstall dh-python
    

    and then retry

    sudo dpkg --configure -a
    sudo apt-get install -f
    sudo apt-get install python3-pip
    sudo apt-get dist-upgrade
    
  • Related Question