/usr/bin/python3: No module named virtualenv error on Linux

I am setting up a new app and Github page said run the following on Ubuntu system:

python3 -m virtualenv env

And I got the error:

/usr/bin/python3: No module named virtualenv

Does anyone know how to fix this?

Nevermind. I figured it out as it was needed immediately. Here is how I fixed it on my Ubuntu development laptop. I am using Python version 3.

1. Install python3-pip

Run as the root user :wink:

sudo apt install python3-pip

2. Install virtualenv using pip3

Then I typed in my $HOME:

pip3 install virtualenv

Files are installed:

Collecting virtualenv
  Downloading virtualenv-20.7.2-py2.py3-none-any.whl (5.3 MB)
     |████████████████████████████████| 5.3 MB 2.3 MB/s 
Collecting platformdirs<3,>=2
  Downloading platformdirs-2.2.0-py3-none-any.whl (13 kB)
Collecting backports.entry-points-selectable>=1.0.4
  Downloading backports.entry_points_selectable-1.1.0-py2.py3-none-any.whl (6.2 kB)
Collecting distlib<1,>=0.3.1
  Downloading distlib-0.3.2-py2.py3-none-any.whl (338 kB)
     |████████████████████████████████| 338 kB 6.4 MB/s 
Collecting filelock<4,>=3.0.0
  Downloading filelock-3.0.12-py3-none-any.whl (7.6 kB)
Requirement already satisfied: six<2,>=1.9.0 in /usr/lib/python3/dist-packages (from virtualenv) (1.14.0)
Installing collected packages: platformdirs, backports.entry-points-selectable, distlib, filelock, virtualenv
Successfully installed backports.entry-points-selectable-1.1.0 distlib-0.3.2 filelock-3.0.12 platformdirs-2.2.0 virtualenv-20.7.2

3. Fixed /usr/bin/python3: No module named virtualenv error

Now I can run the following and make a virtual environment to isolate dependencies from other packages on my dev system.

python3 -m virtualenv env
source env/bin/activate

Finally I was able to install needed packages using the requirements.txt given by Github:

pip3 install -r requirements.txt

Haha :stuck_out_tongue:

Linux sysadmin blog - Linux/Unix Howtos and Tutorials - Linux bash shell scripting wiki