pyvenv not working because ensurepip is not available

Louis M picture Louis M · Sep 16, 2016 · Viewed 57.1k times · Source

I upgraded from ubuntu 14.04 to ubuntu 16.04 a few days ago. When I try to create a virtual env by using

pyvenv .venv

or

python3 -m venv .venv

There is an error:

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: ['/usr/bin/python3.5', '-Im', 'ensurepip', '--upgrade', '--default-pip']

I tried running both

sudo apt-get install python3-venv

and

sudo apt-get install python3.5-venv

but it did not solve my problem.

Answer

Louis M picture Louis M · Sep 16, 2016

It seems that it was a locale problem. Solved by executing:

export LC_ALL="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"
sudo dpkg-reconfigure locales

found on this thread Python locale error: unsupported locale setting