How to use Python virtual environment

This is just a note for my personal VS Code Editor.

  1. Install Python3 Package in the computer

    https://www.python.org/downloads/

  2. Create a virtual environment

    # .venv is a director for my own virtual environment
    python -m venv .venv
  3. Activate a virtual environment

    source .venv/Scripts/activate
  4. Select a virtual environment in VS Code Editor

    Use Ctrl+Shift+P to go to VS Code Editor, and Select Python: Select Interpreter. Then, choose your own virtual environment name.

  5. Deactivate a virtual environment

    source .venv/Scripts/deactivate