Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to install virtualenv on Ubuntu 20.04 GCP instance?

I am trying to install python3 virtualenv. I get the following message when I try to run virtualenv.

virtualenv
Command 'virtualenv' not found, but can be installed with:
apt install python3-virtualenv

but if I run install command, I get the following error.

apt install python3-virtualenv
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package python3-virtualenv

For python3 -m venv, I get message to install using apt-get install python3-venv but when I try it, I get the same message.

sudo apt-get install python3-venv
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package python3-venv is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'python3-venv' has no installation candidate

I am running this as root. wget also works.

like image 668
RedFox Avatar asked Jun 10 '20 23:06

RedFox


People also ask

Should I use VENV or virtualenv?

These are almost completely interchangeable, the difference being that virtualenv supports older python versions and has a few more minor unique features, while venv is in the standard library.


6 Answers

AFAIU the latest versions of Ubuntu removed Python2 altogether so Python3 is now just the Python. Try:

apt-get update
apt-get install python3-virtualenv
like image 156
phd Avatar answered Nov 07 '22 00:11

phd


try type in terminal:

sudo apt-get install python3.8-venv

and then try again install virtualenv

like image 32
artix97 Avatar answered Nov 07 '22 00:11

artix97


The below is very similar to the answer by phd, but my freshly installed Ubuntu 20.04 still requires the python version number:

apt-get update
apt-get install python3-virtualenv
like image 22
dr.Pep Avatar answered Nov 06 '22 22:11

dr.Pep


This will definitely work:

sudo apt-get update
sudo apt-get install python3-virtualenv
like image 45
Cyril Mukabwa Avatar answered Nov 06 '22 23:11

Cyril Mukabwa


I was getting the error E: Unable to locate package python3-virtualenv because I had to run apt-get update first. This was my brand new GCP instance.

Reference: first comment of the first answer in this thread. Unable to locate package virtualenv in ubuntu-13 on a virtual-machine

Thank you all.

like image 40
RedFox Avatar answered Nov 06 '22 23:11

RedFox


sudo apt install python3-virtualenv

like image 37
Desarrollalab Avatar answered Nov 07 '22 00:11

Desarrollalab