Ubuntu: I accidentally deleted usr/lib/python3.4 and now I'm having some problems, how can I fix this?



Question:

(This is not a duplicate of Accidentally deleted /usr/lib/python3.4, the errors I get are different.)

Today I accidentally deleted usr/lib/python3.4, now Ctrl+Alt+T is not working anymore, terminal and unity-tweak-tool are not opening from the app drawer.

I get this error while I try to open unity-tweak-tool from the terminal. How can I fix this?

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

UPDATE
After running sudo apt install --reinstall $(dpkg -S /usr/lib/python3.* | sed -r 's/, /\n/g; s/\: .+//') it reinstalled some things but at the end it gave me another error: E: Internal Error, No file name for python3.4:amd64. After running unity-tweak-tool I now get:

Could not find platform independent libraries <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 0x00007f06bc180700 (most recent call first):  (core dump created)  


Solution:1

Several Python packages keep their in there so reinstalling one might not do it. See what has files in there on your system by running:

dpkg -S /usr/lib/python3.4  

That will return something slightly different for everybody but the important part is reinstalling the packages it shows.

It needs a bit of processing (removing commas, chopping off the path), but here's something that does all that and gets them reinstalled.

sudo apt install --reinstall $(dpkg -S /usr/lib/python3.* | sed -r 's/, /\n/g; s/\: .+//')  

In some cases you might have to prioritise (install them first) some packages over others manually but see what you get.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »