3

When attempting apt upgrade or apt update-manager I receive the following error:

Setting up update-notifier-common (3.168.1) ...
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'

Current thread 0x00007fa215e86700 (most recent call first):
Aborted (core dumped)
dpkg: error processing package update-notifier-common (--configure):
 subprocess installed post-installation script returned error exit status 134
dpkg: dependency problems prevent configuration of flashplugin-installer:
 flashplugin-installer depends on update-notifier-common (>= 0.119ubuntu2); however:
  Package update-notifier-common is not configured yet.

dpkg: error processing package flashplugin-installer (--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:
 update-notifier-common
 flashplugin-installer
E: Sub-process /usr/bin/dpkg returned an error code (1)

I've read through the many duplicate questions, and none of the solutions have worked for me.

Using Ubuntu 14.04, with Python 2.7.12 default, I manually installed Python 3.5 from source. I have never used a virtual environment to deal with the multiple versions. Since I'm very new to Ubuntu, I without thinking deleted many files and directories for Python3.5 from /usr/lib though there are still Python3 and Python3.5 files in /usr/bin. Despite the fatal error, Python 2.7.12 still works perfectly in shell, and python -V still says 2.7.12 is the default version.

The above error results after unsetting both $PYTHONHOME and $PYTHONPATH. If echo $PYTHONHOME returns nothing, and then I enter PYTHONHOME in the command line, I receive the following error (likewise for entering PYTHONPATH):

Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'

Current thread 0x00007f57373f3700 (most recent call first):
Aborted (core dumped)

When I enter which python the command line returns /usr/bin/python, and that file does have as its link target Python2.7. If I then set export PYTHONHOME=/usr and again enter PYTHONHOME into the command line, I get the following error:

Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'

Current thread 0x00007f3de267e700 (most recent call first):
Aborted (core dumped)

When I move my command line directory to my python directory and enter python -m encodings I receive the following:

/usr/bin/python: No module named encodings.__main__; 'encodings' is a package and cannot be directly executed

...so I'm not even sure how I would make PYTHONPATH aware of it as a module if it apparently is not a module. And regardless of how I set PYTHONHOME or PYTHONPATH, I have so far continued to get the same error when I run apt upgrade.

Some other fixes I've attempted:

  • All these commands run without a problem, but do not fix the error

    apt update
    apt clean
    apt autoclean
    
  • apt autoremove and apt-get -f install both yield the same error as apt upgrade

  • unsetting PYTHONPATH and PYTHONHOME does not fix the error, nor does setting PYTHONHOME to the directory indicated by which python
  • I attempted to use the Synaptic package manager to fix broken packages, but this didn't fix the error.
  • I checked to make sure that /usr/lib/command-not-found explicitly calls /usr/bin/python3, and that file does exist (I didn't delete it).
  • My /lost+found directory is currently empty, so there are no modules to restore from there.
  • Using apt-get install --reinstall python (and the same command with python3.5) yields the same error as apt upgrade.

I've found no other resources or answers to deal with this error. Should I try using a virtual environment to isolate the remaining files of my python versions? Should I attempt to fix my now corrupted manual installations of python3.5, and how would I do so since --reinstall python yields a fatal error?

  • 6
    One does not simply delete libraries from /usr/lib – Anwar Sep 15 '16 at 7:53
  • 3
    I realize that this is all my fault and I shouldn't have mucked around deleting protected files, but does anyone have any advice on how I could better format or phrase this question? I tried to exhaustively search through all the duplicate questions and provide as much info as I could. – Alexander Eichner Sep 15 '16 at 10:19

Your Answer

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

Browse other questions tagged or ask your own question.