Monday, March 28, 2022

[SOLVED] Create Virtual Environment using Python Documentation

Issue

I am very new at command line usage. I am using python 3.7.2, Bash and VSCode Integrated Terminal. I am trying to create a virtual environment using venv and following python documentation:

https://docs.python.org/3/tutorial/venv.html#creating-virtual-environments

The command to use is this one:

$ python3 -m venv test-env

and I get:

bash: python3: command not found

Later I have found a similar answer in an stackoverflow post:

How to create and activate virtual environment in windows 10 using bash command

And I use the command:

py -m virtualenv test-env

and I get this:

No module named virtualenv

I am very new using the command line so i don´t really know what is going on and how to work it around.


Solution

Hi i can see that you are using two different tools to create your environment. Those are "venv" and "virtualenv". Venv is a library that already comes with your python installation. Virtualenv is an external one. I had the same problem before and the solution is very simple. I recommend you to stick with venv because it works pretty ok and you don´t need to do extra job installing external libraries. So for solving your problem the Bash Shell is telling you that the command Python3 has not been found. So try instead just: python -m venv test-env

Sometimes Python documentation is not accurate enough and I know when you start using commands, accuracy in the sintax is extremely important.



Answered By - Mario Andrés Ravina
Answer Checked By - Willingham (WPSolving Volunteer)