Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing venv for python3 in WSL (Ubuntu)

Tags:

I am trying to configure venv on Windows Subsystem for Linux with Ubuntu.

What I have tried:

1) Installing venv through pip (pip3, to be exact)

pip3 install venv

I get the following error

ERROR: Could not find a version that satisfies the requirement venv (from versions: none)
ERROR: No matching distribution found for venv

2) Installing venv through apt and apt-get

sudo apt install python3-venv

In this case the installation seems to complete, but when I try to create a virtual environment with python3 -m venv ./venv, I get an error, telling me to do apt-get install python3-venv (which I just did!)

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: ['/mnt/c/Users/Vicubso/.../code/venv/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']

I have also read the following posts post 1, post 2, and several others. None of these seem to solve my problem.

Any help would be much appreciated.

like image 854
vicubso Avatar asked Apr 30 '20 16:04

vicubso


People also ask

Does venv come with python3?

venv is a package that comes with Python 3.


1 Answers

Nothing here worked for me, but this did in WSL2:

sudo apt-get update
sudo apt-get install libpython3-dev
sudo apt-get install python3-venv
python3.8 -m venv whatever

Good luck!

like image 168
trpt4him Avatar answered Sep 24 '22 00:09

trpt4him