Virtual Environment - Python

  • Tool used to isolate specific python environments on a single machine, allowing you to work on multiple projects with different dependencies and packages without conflicts
  • python -m vnev myenv => Creates a folder
  • source myenv/bin/activate => Activate "myenv" environment, For Linux/Mac
    • myenv\Scripts\activate.bat => For windows
    • myenv\Scripts\activate.ps1 => For windows powershell
  • deactivate => Deactivate
  • pip freeze => Outputs list of installed packages and their versions
    • pip freeze > requirements.txt => Creates a file which contains list of installed packages and their versions
    • pip install -r requirements.txt => Install packages in the list
Share: