×
   ❮   
PYTHON FOR DJANGO DJANGO FOR BEGINNERS DJANGO SPECIFICS PAYMENT INTEGRATION Roadmap
     ❯   

VIRTUAL ENVIRONMENT

Installation

Virtual Environment Installation in Python for Django

Setting up a virtual environment is the first step in isolating your Django project’s dependencies. In this guide, we’ll cover how to install and configure a virtual environment using the built-in venv module and alternatives like virtualenv.

Step 1: Install Python

Ensure Python is installed on your system. You can verify this by running python --version or python3 --version in your terminal or command prompt.

Step 2: Installing a Virtual Environment

  • Using venv (Recommended):

    Python 3 comes with venv by default, which you can use to create virtual environments:

    python -m venv myenv

    This will create a folder named myenv, which contains the isolated Python environment for your project.

  • Using virtualenv (Optional):

    If you're using an older version of Python, you might need virtualenv. Install it via pip:

    pip install virtualenv

    Create an environment with:

    virtualenv myenv

Step 3: Verify Installation

After creating your virtual environment, verify its existence by checking the directory structure. You should see bin or Scripts (depending on your OS) containing the necessary executables.

Conclusion

Now that your virtual environment is set up, you’re ready to move on to activating it. The next subtopic covers how to activate and use this environment in your Django projects.