Run this line by line, or as a whole

I am trying to install flask. Docs say to make an environment:

Create an environment

Create a project folder and a venv folder within:

Windows

mkdir myproject
cd myproject
py -3 -m venv venv

How should I run those?

  • one line at a moment and the other?

  • all in a one or write a bash-y script?

I am on cmd.exe, Windows 7.


How should I run these?

Each line is a separate command in cmd, so they should be run one at a time:

  1. mkdir myproject
  2. cd myproject
  3. py -3 -m venv venv

Note that line 3 assumes you have installed py launcher (e.g. as part of the installation process with "vanilla" Python for Windows) and that it is available from the command line (checked via where py in cmd). Regarding the command itself:

  • The -3 portion specifies the use of whatever default version of Python 3 py launcher is aware of.

  • -m venv invokes the native Python venv (virtual environment) module.

  • The final venv is the "name" (path) of the virtual environment created (i.e. what the folder created holding the necessary venv files will be called).

Be aware that any virtual environment will need to be "activated" in each new cmd window you open, if you intend to use it (i.e. use the modules you install in them, including flask). That is, you will need to run some version of:

C:\path\to\venv\scripts\activate.bat

each time you wish to use flask in a new cmd window.

Personally, I have a preference for creating batch file "aliases" with just the appropriate line e.g.:

ex. py_flask.bat

C:\path\to\venv\scripts\activate.bat

and placing those files (py_flask.bat) in a folder available in my Windows System Path environment variables. This allows the use of just e.g. py_flask from any open cmd window to activate the associated environment and avoid typing a (likely) longer full path.


You should run the commands one line at a time.