1

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.

1
  • It worked using just the command: python -m venv test-env. Commented May 28, 2019 at 10:02

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

0

Try this steps,it'll helped you:

  1. First, make a directory :
mkdir testing
  1. Then, moved to this directory named testing :
cd testing
  1. When you type following command in this directory:
python3 -m venv env  (OR, python -m venv env)

You got error like :

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 install python3.8-venv
  1. Type the following command but before that keep an eye on the version of python you installed on the machine; in my case its python3.8
sudo apt install python3.8-venv
  1. Now, we can create a virtual environment and store its tools in the "bhandari" folder .
python3 -m venv bhandari   

Note: you can named this "bhandari" folder; anyname you like( Standard practice is to name it "env" ...)

  1. Now to activate your virtual environment, from the directory of your folder, type the following command this will activate our virtual environment in the “bhandari” folder
source bhandari/bin/activate
  1. If you have successfully activated your virtual environment, you should see the (bhandari) word indicating that we are working in a virtual environment.

After this, we can install anything that will be isolated from the rest of the system....

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.