Ubuntu 18.04 LTS python error


Hi community , as I did my research on python for reasons that it is running not as it should be. i tried to reinstall it manually, but it doesn’t seem to work. i tried installing python2 and python3 through terminal, but i still getting an error message:

Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)

that message pops at the last 3 lines in my terminal.
when i want to check for the version of my python it shows a different long messages that does not mean a lot to me (I’ll write the start of the text and the end of it you may figure it out):

import _frozen_importlib # frozen
import _imp # builtin
import 'rlcompleter' # <_frozen_importlib_external.SourceFileLoader object at 0x7f54b0c643c8>

yet it doesn’t get me back to the home $ to use terminal and i have to Ctrl+z to go back as canceling the action.
I’m still a beginner to Linux so please bare with me for I don’t have all the right words to describe my problem or even give you the proper info to help me out.
Thank you



Welcome to our forums.

In terms of the:

This may be caused but multiple events. More information is required on what are you trying to do and what commands you have executed. Copy and paste the entire terminal including your command here.

This is a python prompt. To get to your shell prompt back simply type exit and hit Enter.

CTRL+z only stops the the python shell instead of exiting. What you need to do is to type exit as explained above.

No worries. I’m more than happy to help.



Hi Mr Lubos,
thank you for replying to me, I will now post what ever you need and said you would want to know more… well first of all I started using exit instead of Ctrl+Z to exit my stuck situations, Thank you very much for that info.
I used:

$ sudo apt install python3
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libpython3-stdlib python3-minimal
Suggested packages:
  python3-doc python3-tk python3-venv
The following packages will be upgraded:
  libpython3-stdlib python3 python3-minimal
3 upgraded, 0 newly installed, 0 to remove and 21 not upgraded.
1 not fully installed or removed.
Need to get 0 B/41.1 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 install-info (6.5.0.dfsg.1-2) ...
/usr/sbin/update-info-dir: 2: /etc/environment: Syntax error: Unterminated quoted string
dpkg: error processing package install-info (--configure):
 installed install-info package post-installation script subprocess returned error exit status 2
Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)

thank you very much Lubos I really appreciate you helping me.


Try the execute the following command to purge the install-info package from the system.

$ sudo apt purge install-info

Next, remove cached packages just in case they are corrupted:

$ sudo apt clean

Next, try to install python3 package again:

$ sudo apt install python3

If the above did not help try to do internal package audit using the dpkg command and see if it returns something suspicious you would be able to act on it:

$ sudo dpkg --audit

Alternatively post here any relevant output/errors etc by using the preformated text.