notes
  • computer-networking
    • extend-wifi-with-router
    • how-the-internet-works
    • idk
    • networking-devices
    • osi-model
    • tcp-ip
    • Types of VPN
  • databases
    • Foreign Keys
    • Redis
    • simple-queries
  • devops
    • ansible
    • Manual deployment
    • docker
    • Workflow file
    • nginx
    • promethues-grafana
    • terraform
  • hardware
    • Power
  • home-server
    • proxmox-basics
    • proxmox-setup
    • storage
  • languages-frameworks
    • programming-paradigms
    • programming-languages
      • Regex Notes
      • c
        • basics
        • pointers-memory
      • cpp
        • basics
        • running-cpp
      • php
        • basics
        • choizez
        • frameworks
          • laravel
      • python
        • venv
        • concepts
          • Using lambda
        • frameworks
          • django
            • django
            • start
      • java
        • advanced
          • functional-programming
          • reactive-programming
        • concepts
          • how-java-works
          • serialization
          • sockets
          • threads
        • extra
          • collection-framework
          • generics-and-wildcards
          • Regular Expressions (Regex)
          • streams
        • frameworks
          • orm
        • fundamentals
          • OOP
          • conditionals
          • data-structures
          • data-types
          • exceptions
          • files
          • Functions (aka method)
          • Loops
          • packages
          • type-casting
      • javascript
        • frameworks
          • morgan
          • Using Sequelize with PostgreSQL in JavaScript
  • operating-system
    • basics
    • linux-directories
    • Basic Unix Terminal Commands
  • others
    • dark-web
    • piracy
  • system-design
    • system-design
  • web-dev
    • full-stack
  • books
    • sicp
      • Recursion thought process
      • 1
        • 1.1
        • 1.2
        • 1.3
      • 2
        • 2.1
  • certifications
    • aws-certified-cloud-practitioner
      • core-services
      • other-services
    • comptia-a+
      • Cloud
      • hardware
      • Important terms
      • Important terms
      • Troubleshooting
  • cloud
    • aws
      • aws-cli
      • aws-ec2-deployment
  • dsa
    • algorithms
      • back-tracking
      • bfs
      • Binary Search
      • bit-manipulation
      • Bubble sort
      • bucket-sort
      • counting-sort
      • dfs
      • Divide & Conquer
      • djikstras-algorithm
      • dynamic-programming
      • external-sorting
      • greedy-algorithm
      • Heap sort
      • Insertion sort
      • kadanes-algorithm
      • Merge sort
      • Permutation
      • quick-sort
      • Radix Sort
      • recurrence-relation
      • recursion
      • Selection sort
      • sliding-window
      • subset
      • time-space-complexity
      • topological-sort
      • tree-traversals
      • Two Pointers Technique
    • data-structures
      • data-structures
  • security
    • authentication
      • What is JWT (JSON Web Token)?
    • software-architecture-design
      • design-patterns
Powered by GitBook
On this page
  • Why use virtual environment?
  • How to create a venv
  1. languages-frameworks
  2. programming-languages
  3. python

venv

Why use virtual environment?

Suppose you have Django version 1.0 already installed on your computer, and you have several projects utilizing it. However, for your latest project, you aim to use Django version 2.0.

To ensure that Django version 2.0 is exclusive to your new project and does not interfere with the existing projects, you opt to create and use a virtual environment (venv) specifically for the new project.

How to create a venv

In your new project

python -m venv .venv

This command creates a .venv folder as a virtual environment.

Activate the virtual environment (activate everytime you start application):

.venv/Scripts/activate

Now, it's time to configure your Integrated Development Environment (IDE) to use the Python interpreter from your virtual environment.

After configuring the IDE, you can install dependencies for your project within the virtual environment. For example, to install Django:

python -m pip install django

This installs Django specifically within your virtual environment, keeping it isolated from your global Python library.

PreviouspythonNextconcepts

Last updated 1 month ago