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

VIRTUAL ENVIRONMENT

Deactivating

Deactivating a Virtual Environment

Once you've completed your work in a virtual environment, it's important to deactivate it properly. This ensures your global Python environment isn’t affected by any changes made inside the virtual environment.

How to Deactivate a Virtual Environment

To deactivate a virtual environment, regardless of the operating system, run the following command in your terminal:

deactivate

This command exits the virtual environment and reverts your terminal to the system-wide Python installation.

What Happens When You Deactivate?

  • The environment variables specific to your virtual environment are reset.
  • Your terminal returns to its default state, using the global Python installation.
  • Your prompt no longer shows the (myenv) tag.

Reactivating a Virtual Environment

If you want to return to your virtual environment, simply use the appropriate activate command for your OS:

  • Windows: myenv\Scripts\activate
  • macOS/Linux: source myenv/bin/activate

Conclusion

Deactivating your virtual environment is a simple process but critical to managing your project environments effectively. Now, let’s move on to managing dependencies using requirements.txt in the next subtopic.