Isolation Made Easy : venv📁in Python

“Big things have small beginnings.” ~ Promethus

Hey there, Python learner..

Setting up a virtual environment (or venv) is an essential part of any Python project.

It helps keep dependencies organized and avoids conflicts with other projects.

He…


This content originally appeared on DEV Community and was authored by Vidya🌞

“Big things have small beginnings.” ~ Promethus

Hey there, Python learner..

Setting up a virtual environment (or venv) is an essential part of any Python project.

It helps keep dependencies organized and avoids conflicts with other projects.

Here’s a quick and friendly guide on:

  • how to create a virtual environment.
  • verify it
  • even check where your packages are being installed._

Step 1: Create the Virtual Environment

To kick things off, open your terminal or command prompt and run this command:

python -m venv venv

You should see a folder named venv—that’s your virtual environment! 🎉

ls

first

second

Step 2: Activate the Virtual Environment⚡

source venv/Scripts/activate

After running this command, your prompt will change to something like below image:👇
third

Step 3: Verify the Active Environment🔍

which python

fourth

fifth

Step 4: Install a Package and Verify Installation📦

Try installing any package, here i am installing boto3 which is an official AWS SDK for python.

pip install boto3

This will show all the packages installed in your virtual environment, including boto3

pip list

sixth

Step 5: Deactivate the Virtual Environment🔒

Once deactivated, run pip list again, it will show the packages installed globally, rather than the ones in your virtual environment.

deactivate venv
pip list

seventh

And that’s it!🎊

You’re set to use virtual environments in Python.

So go ahead—give it a try!

Always remember: Experiment, break things, fix them, and watch your projects run smoothly.🚀


This content originally appeared on DEV Community and was authored by Vidya🌞


Print Share Comment Cite Upload Translate Updates
APA

Vidya🌞 | Sciencx (2024-10-26T12:32:14+00:00) Isolation Made Easy : venv📁in Python. Retrieved from https://www.scien.cx/2024/10/26/isolation-made-easy-venv%f0%9f%93%81in-python/

MLA
" » Isolation Made Easy : venv📁in Python." Vidya🌞 | Sciencx - Saturday October 26, 2024, https://www.scien.cx/2024/10/26/isolation-made-easy-venv%f0%9f%93%81in-python/
HARVARD
Vidya🌞 | Sciencx Saturday October 26, 2024 » Isolation Made Easy : venv📁in Python., viewed ,<https://www.scien.cx/2024/10/26/isolation-made-easy-venv%f0%9f%93%81in-python/>
VANCOUVER
Vidya🌞 | Sciencx - » Isolation Made Easy : venv📁in Python. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/10/26/isolation-made-easy-venv%f0%9f%93%81in-python/
CHICAGO
" » Isolation Made Easy : venv📁in Python." Vidya🌞 | Sciencx - Accessed . https://www.scien.cx/2024/10/26/isolation-made-easy-venv%f0%9f%93%81in-python/
IEEE
" » Isolation Made Easy : venv📁in Python." Vidya🌞 | Sciencx [Online]. Available: https://www.scien.cx/2024/10/26/isolation-made-easy-venv%f0%9f%93%81in-python/. [Accessed: ]
rf:citation
» Isolation Made Easy : venv📁in Python | Vidya🌞 | Sciencx | https://www.scien.cx/2024/10/26/isolation-made-easy-venv%f0%9f%93%81in-python/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.