Accidentally deleted /usr/bin/python3.5, cannot reinstall

6,980

I fixed it.

Find all dependencies:

dpkg -l | grep python3.5

Remove all of them:

apt-get --purge remove libpython3.5 libpython3.5-dev libpython3.5-minimal libpython3.5-stdlib python3.5 python3.5-dev python3.5-minimal

Reinstall

apt-get install python3.5-dev
Share:
6,980

Related videos on Youtube

Mithril
Author by

Mithril

Updated on September 18, 2022

Comments

  • Mithril
    Mithril over 1 year

    OS: Ubuntu 14.04

    I have seen a similar question, but none of the methods mentioned there work.

    I installed python 3.5 by running:

    apt-get install -y software-properties-common && \
    add-apt-repository ppa:fkrull/deadsnakes && \
    apt-get update
    apt-get install -y python3.5 python3.5-dev
    

    I make a mistake by running ln -sf /usr/bin/python /usr/bin/python3.5, so the symlink to python3.5 become python2.7 .

    I have tried:

    1.

    rm -f /etc/apt/sources.list.d/*
    dpkg --configure -a
    add-apt-repository ppa:fkrull/deadsnakes
    apt-get update
    apt-get install --reinstall python3.5 python3.5-dev
    

    2.

    apt-get remove --purge python3.5 python3.5-dev
    apt-get install python3.5 python3.5-dev
    

    In both cases I got something like:

    /var/lib/dpkg/info/python3.5.postinst: 9: /var/lib/dpkg/info/python3.5.postinst: python3.5: not found
    dpkg: error processing package python3.5 (--configure):
     subprocess installed post-installation script returned error exit status 127
    dpkg: dependency problems prevent configuration of python3.5-dev:
     python3.5-dev depends on python3.5 (= 3.5.2-1~trusty1); however:
      Package python3.5 is not configured yet.
    
    dpkg: error processing package python3.5-dev (--configure):
     dependency problems - leaving unconfigured
    Errors were encountered while processing:
     python3.5
     python3.5-dev
    E: Sub-process /usr/bin/dpkg returned an error code (1)
    
    • George Udosen
      George Udosen over 7 years
      remove the link with rm /usr/bin/python3.5 then try installing again.
    • Mithril
      Mithril over 7 years
      @George I have rm /usr/bin/python3.5 at first.
  • CoderGuy123
    CoderGuy123 over 3 years
    Worked on Ubuntu 18.04 for me (after an upgrade from 16.04, Python3.7 was broken and actually a copy of Python2.7, yeah, no idea either why that is).
  • Orville
    Orville over 3 years
    worked on python3.7. save my day thanks!
  • Viter Rod
    Viter Rod over 2 years
    worked on ubuntu 20.04 with Python3.9. Thanks!