Skip to content

Instantly share code, notes, and snippets.

@RahulDas-dev
Last active August 20, 2022 15:04
Show Gist options
  • Save RahulDas-dev/4324ec7d7f60ff49efd33180c33e6a28 to your computer and use it in GitHub Desktop.
Save RahulDas-dev/4324ec7d7f60ff49efd33180c33e6a28 to your computer and use it in GitHub Desktop.
Python virtual environment creation using venv module

Create Environment using venv Module

  • For Windows python -m venv --prompt <venv_promt> <venv_directory>
  • For Linux python3 -m venv --prompt <venv_promt> <venv_directory>

Activate Environment

  • For Windows <venv_directory>\Scripts\activate.bat
  • For Linux source <venv_directory>/bin/activate

Check Environment Creation

  • For Windows where python, should return new python path
  • For Linux which python3 should return new python path

Package Installation

  • For Windows python -m pip install -r requirements.txt or pip install <package name>
  • For Linux python3 -m pip install -r requirements.txt or pip3 install <package name>

List down Installed Packages

  • For Windows python -m pip freeze --local .
  • For Linux python3 -m pip freeze --local or python3 -m pip install <package name>
@RahulDas-dev
Copy link
Author

In Windows with command python -m venv --prompt sfm .venv

venv Prompt = sfm
venv Directory = .venv

venv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment