I have an Distributor ID: Ubuntu Description: Ubuntu 18.04.4 LTS Release: 18.04 Codename: bionic Python 2.7.17

I am installing OpenCV and even python 3 too. To install python 3, I used the following commands

sudo apt-get install python3-dev

$ wget https://bootstrap.pypa.io/get-pip.py

$ sudo python3 get-pip.py

Later, I messed up linking OpenCV with the installed version of python.So, I thought of deleting python3 and installing it. For that I used the command

apt-get autoremove py(completing the line with tab+tab)

I got a long list and when I tried to do

apt-get autoremove python3

I got an error as

E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied) E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?

What I want to do is remove the python 3 I installed, but confused and worried about what to do.Because the results show python 3 as well as python 3.6. Would appreciate any help. I have attached a screenshot of the commands and output.screenshot

  • 1
    In Ubuntu python = python2.x, python3 = python3.x. You can see with python3 -V
    – doug
    Mar 5, 2020 at 17:00

2 Answers 2


First, you didn't really install Python3. Instead, you installed additional modules to the stock Python3 that came with your system.

Second, DO NOT remove the stock Python3 (and additional components) that came with your Ubuntu system. Essential system services --like apt-- use Python3, Removing all of Python3 will break your system quite horribly.

  • Check your /var/log/apt logs to see exactly what you really installed...and is therefore safe to remove.

  • The "Permission Denied" error you encountered was due to a simple typo you did, and is unrelated to destroying your system by removing Python3.

  • But when I run python -V I get Python 2.7.17, which I guess has come with the Ubuntu System. Or is it that both Python 2.7.17 and Python 3 both have come together?
    – Hrushi
    Mar 5, 2020 at 17:12
  • 1
    Classic Python confusion: python refers only to Python2, never to Python3. python3 refers only to Python3. Older releases of Ubuntu (like yours) did indeed ship with BOTH, as the 2-to-3 conversion took several years. Newer releases of Ubuntu (like 19.10 and 20.04) ship with Py3 only. Apt in 18.04 requires Py3. Apt in 18.04 won't work with Py2.
    – user535733
    Mar 5, 2020 at 17:16

When you want to run program with python v.3.x just use python3 filename.py It will run with python version you specified. So if you have multiple Python versions installed in your ubuntu system, Specify the version.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.