{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "provenance": [], "authorship_tag": "ABX9TyMmQmdne96MzUKygHRgHbly", "include_colab_link": true }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "language_info": { "name": "python" } }, "cells": [ { "cell_type": "markdown", "metadata": { "id": "view-in-github", "colab_type": "text" }, "source": [ "\"Open" ] }, { "cell_type": "markdown", "source": [ "# Understanding Virtual Environments in Python\n", "\n", "## Master Efficient Data Storage and Retrieval with Python\n", "\n", "| ![space-1.jpg](https://github.com/Tanu-N-Prabhu/Python/blob/master/Img/virtual_env.png?raw=true) |\n", "|:--:|\n", "| Image Generated Using Canva|\n", "\n", "#### Introduction\n", "When you're working on multiple Python projects, you might run into version conflicts, one project needs `Django 3.x`, another needs `Django 4.x`. Virtual environments solve this problem! They create isolated spaces for each project, ensuring dependencies don’t clash and projects stay clean and manageable. Today, let's dive into how virtual environments work and why they're a must for professional development.\n", "\n", "---\n", "\n", "#### Why It’s So Important?\n", "* It keeps project dependencies isolated.\n", "* It avoids version conflicts.\n", "* It makes your projects easily reproducible.\n", "* The professional standard for real-world development.\n", "\n", "---\n", "\n", "#### Code Implementation" ], "metadata": { "id": "Gm7uUS7t-SeQ" } }, { "cell_type": "code", "source": [ "# Step 1: Install virtualenv (if you haven't)\n", "pip install virtualenv\n", "\n", "# Step 2: Create a virtual environment\n", "virtualenv myprojectenv\n", "\n", "# Step 3: Activate the environment\n", "# On Windows\n", "myprojectenv\\Scripts\\activate\n", "\n", "# On Mac/Linux\n", "source myprojectenv/bin/activate\n", "\n", "# Step 4: Install project dependencies\n", "pip install django==3.2\n", "\n", "# Step 5: To deactivate\n", "deactivate" ], "metadata": { "id": "kD0pzSME-raT" }, "execution_count": null, "outputs": [] }, { "cell_type": "markdown", "source": [ "##### Notes\n", "* Each environment has its own Python binary and can have different versions of libraries.\n", "* You can even have different Python versions inside environments using tools like pyenv.\n", "\n", "---\n", "\n", "#### Conclusion\n", "Virtual environments are not just a \"nice to have\", they are essential for clean, organized, and scalable Python development. Whether you're working solo or in a team, mastering virtual environments will make your coding life much smoother! Thanks for reading my article, let me know if you have any suggestions or similar implementations via the comment section. Until then, see you next time. Happy coding!\n", "\n", "---\n", "\n", "#### Before you go\n", "* Be sure to Like and Connect Me\n", "* Follow Me : [Medium](https://medium.com/@tanunprabhu95) | [GitHub](https://github.com/Tanu-N-Prabhu) | [LinkedIn](https://ca.linkedin.com/in/tanu-nanda-prabhu-a15a091b5) | [Python Hub](https://github.com/Tanu-N-Prabhu/Python)\n", "* [Check out my latest articles on Programming](https://medium.com/@tanunprabhu95)\n", "* Check out my [GitHub](https://github.com/Tanu-N-Prabhu) for code and [Medium](https://medium.com/@tanunprabhu95) for deep dives!" ], "metadata": { "id": "q-O_5Uza-t1P" } } ] }