Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python3.8-venv not working with python3.8 -m venv env

I want to create a venv having python3.8 as python3 On Ubuntu 18.04 I did:

> sudo apt install python3.8 python3.8-venv

Now, when I try:

> python3.8 -m venv env

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/pushp/vizio-backend/env/bin/python3.8', '-Im', 'ensurepip', '--upgrade', '--default-pip']

My application depends on python3.8. What am I missing here?

like image 269
Pushp Vashisht Avatar asked Jul 07 '20 10:07

Pushp Vashisht


3 Answers

first: sudo pip3 install virtualenv then cd to the directory where you want your virtual environment to be: virtualenv "name of env" for ex: sudo virtualenv myProject-env then to activate: sudo source myProject-env/bin/activate to make sure that it is work: sudo which python

like image 99
Kevin Omar Avatar answered Nov 14 '22 07:11

Kevin Omar


Resolved, what I did? :

apt install python3.8 python3.8-venv python3-venv

Dont know how but installing both the venv packages python3.8-venv python3-venv resolved it from me. Now when I do:

python3.8 -m venv env
source env/bin/activate
python3 --version
> Python 3.8.0
like image 35
Pushp Vashisht Avatar answered Nov 14 '22 08:11

Pushp Vashisht


Installing python3-distutils also works around the problem.

like image 1
Rob Avatar answered Nov 14 '22 07:11

Rob