Linux Mint 13 Problem - No module named site

9,410

After discussion with the poster on chat, starting http://chat.stackexchange.com/transcript/message/20047753#20047753, it turned out the poster's machine is missing /usr/lib/python2.7, see http://chat.stackexchange.com/transcript/message/20052960#20052960. This accounts for most of the poster's problems. In particular, the errors:

Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
ImportError: No module named site

stem from these missing libraries.

The next thing to do is to restore the base Python libraries under /usr/lib/python2.7. One way to do this is to download the deb files corresponding to python2.7, python2.7-minimal and libpython2.7, and then install them using dpkg -i. I.e.

apt-get download python2.7 python2.7-minimal libpython2.7
dpkg -i python*.deb

Once this is done, hopefully the package system will stop freaking out. Then install debsums, if it is not already installed, and restore the remaining missing files using debsums -as.

Share:
9,410

Related videos on Youtube

MichaelJohn
Author by

MichaelJohn

I have been in IT for thirty years with experience in about a dozen programming languages. Most of my work has been in "C" and VB6, although I have also worked with languages as diverse as LISP and Fortran. In addition I have considerable experience of database design and SQL. I started with Python a few days ago.

Updated on September 18, 2022

Comments

  • MichaelJohn
    MichaelJohn almost 2 years

    My Linux Mint 13 64-bit system has developed a problem. Whilst I can run basic commands like ls and vi if I try anything more complex (I have tried python2.7, mysql-workbench and adduser) I get:-

    Could not find platform independent libraries <prefix>
    Could not find platform dependent libraries <exec_prefix>
    Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
    ImportError: No module named site
    

    I went to another system (Mint 13 32-bit) and ran:

    # echo $PYTHONHOME,
    

    and got a blank line so no idea what

    <prefix>[:<exec_prefix>]
    

    are?

    Unsure where to go next?

    After further Googling I tried both “sudo dpkg –configure -a” and “sudo apt-get install -f ” with the following results:-

    HP-255-G1 # sudo dpkg --configure -a
    dpkg: dependency problems prevent configuration of python-appindicator:
    python-appindicator depends on libappindicator1 (= 0.4.92-0ubuntu1);
    however:
    Version of libappindicator1 on system is 0.4.92-0ubuntu1.1.
    dpkg: error processing python-appindicator (--configure):
    dependency problems - leaving unconfigured
    dpkg: dependency problems prevent configuration of python-uno:
     python-uno depends on libreoffice-core (= 1:3.5.2-2ubuntu1); however:
    Version of libreoffice-core on system is 1:3.5.7-0ubuntu7.
    dpkg: error processing python-uno (--configure):
    dependency problems - leaving unconfigured
    Errors were encountered while processing:
    python-appindicator
     python-uno
    
    HP-255-G1 # sudo apt-get install -f
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    Correcting dependencies... Done
    The following extra packages will be installed:
    python-appindicator python-uno
    The following packages will be upgraded:
    python-appindicator python-uno
    2 upgraded, 0 newly installed, 0 to remove and 690 not upgraded.
    2 not fully installed or removed.
    E: Could not get lock /var/cache/apt/archives/lock - open (11: Resource temporarily unavailable)
    E: Unable to lock directory /var/cache/apt/archives/
    

    So it looks as if “python-uno” and "python-appindicator" are central to some of the issues but where to now?

    Here is the requested output:-

    HP-255-G1# apt-cache policy python-uno python-appindicator
    python-uno:
    Installed: 1:3.5.2-2ubuntu1
    Candidate: 1:3.5.7-0ubuntu7
    Version table:
    1:3.5.7-0ubuntu7 0
    500 http://archive.ubuntu.com/ubuntu/ precise-updates/main amd64 Packages
    500 http://security.ubuntu.com/ubuntu/ precise-security/main amd64 Packages
    *** 1:3.5.2-2ubuntu1 0
    500 http://archive.ubuntu.com/ubuntu/ precise/main amd64 Packages
    100 /var/lib/dpkg/status
    python-appindicator:
    Installed: 0.4.92-0ubuntu1
    Candidate: 0.4.92-0ubuntu1.1
    Version table:
    0.4.92-0ubuntu1.1 0
    500 http://archive.ubuntu.com/ubuntu/ precise-updates/main amd64 Packages
    *** 0.4.92-0ubuntu1 0
    500 http://archive.ubuntu.com/ubuntu/ precise/main amd64 Packages
    100 /var/lib/dpkg/status
    

    I managed to get the Synaptic Package Manager running from the command line and tried to update python-uno and python-appindicator. This failed but hopefully the output (below) is another clue:-

    E: /var/cache/apt/archives/python-appindicator_0.4.92-0ubuntu1.1_amd64.deb:
    subprocess new pre-removal script returned error exit status 1
    E: /var/cache/apt/archives/python-uno_1%3a3.5.7-0ubuntu7_amd64.deb:
    subprocess new pre-removal script returned error exit status 1
    
    • MichaelJohn
      MichaelJohn over 9 years
      Have expanded after trying additional command line fixes...
    • Alen Milakovic
      Alen Milakovic over 9 years
      Output of apt-cache policy pkg1 pkg2 where pkgi are the packages mentioned in the error messages. Paste in the question, not in the comments. And don't use a pastebin.
    • Alen Milakovic
      Alen Milakovic over 9 years
      No, you need to give that output for all packages mentioned. You haven't. Also, if you want to hop into the main U&L chat room (you have enough rep) this would probably be easier to sort out interactively. You can ping me once you are there.
  • MichaelJohn
    MichaelJohn over 9 years
    Just tried to downland and got this. In and out till after 13:00 GMT and will go to forum then... # apt-get download python-2.7 python2.7-libpython2.7-minimal E: Unable to locate package python-2.7 E: Couldn't find any package by regex 'python-2.7' E: Unable to locate package python2.7-libpython2.7-minimal E: Couldn't find any package by regex 'python2.7-libpython2.7-minimal'
  • Alen Milakovic
    Alen Milakovic over 9 years
    Don't run apt-get download as root. Only run installation commands as root. Post your /etc/apt/sources.list in the question. Make sure to run apt-get update before running any apt-get command.
  • MichaelJohn
    MichaelJohn over 9 years
    After another session (on the forum) yesterday all up and running now. Many thanks Faheem Mitha...