Ensurepip is not found despite successfully installing python3-venv and python3.8-venv

Question:

I have gotten these consecutive errors, despite having properly installed the required dev libs and the venv lib.

here is the consecutive output in terminal.

~/Desktop/virtualenvs$ python3.8 -m venv newpy38
The virtual environment was not created successfully because ensurepip is not
available.  On Debian/Ubuntu systems, you need to install the python3-venv
package using the following command.

    apt-get install python3-venv

You may need to use sudo with that command.  After installing the python3-venv
package, recreate your virtual environment.

Failing command: ['/home/dji/Desktop/virtualenvs/newpy38/bin/python3.8', '-Im', 'ensurepip', '--upgrade', '--default-pip']

When i run sudo apt-get to ascertain i have installed the venv library

~/Desktop/virtualenvs$ sudo apt-get install python3-venv
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python3-venv is already the newest version (3.6.7-1~18.04).
0 upgraded, 0 newly installed, 0 to remove and 458 not upgraded.

When i run sudo apt-get to ascertain, again, i have installed the venv library

~/Desktop/virtualenvs$ sudo apt-get install python3.8-venv
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python3.8-venv is already the newest version (3.8.0-3~18.04.1).
0 upgraded, 0 newly installed, 0 to remove and 458 not upgraded.

I have also tried the following links but to no avail:

  1. python3.8-venv not working with python3.8 -m venv env
  2. pyvenv not working because ensurepip is not available
  3. I have also resetted by locales with "sudo dpkg-reconfigure locales" as in https://askubuntu.com/questions/33025/locale-settings-are-not-right-how-can-i-reset-them. But this is likely unrelated.

=== Update ===
Somehow, uninstalling and reinstalling python solved this venv issue. I am also not sure why.

Asked By: fatbringer

||

Answers:

Turns out this was because of a broken python installation ! Due to poor (and un-careful) usage of sudo apt-get update sudo apt-get autoremove, i ended up with a broken installation of python, which was unable to properly find its installed libraries

I reinstalled python and it is ok now.

EXTRA NOTE:
As i am using this on an embedded computer (dji manifold2g), some users may not have that easy option of reinstalling python. Re-flashing the whole firmware (which comes pre-installed with python) might actually be more helpful, albeit more inconvenient.

Answered By: fatbringer
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.