What is a Virtual Environment in Python?

Published: 26 March 2022
on channel: Sam Westby Tech
6,387
218

In this video you will learn all about virtual environments in Python. I include commands for Mac, Windows, and Linux. I also cover venv verses virtualenv.
Why use them
What are they
How to use them
When to use them

Subscribe for more coding tutorials :) https://www.youtube.com/samwestbytech...

I may earn commission if you purchase from the links below:

MY CAMERA: https://amzn.to/3reaDlK
MY MICROPHONE: https://amzn.to/3fhunSN
MY LIGHTING: https://amzn.to/3dHll1i

FREE Amazon Prime: https://amzn.to/3ren80W
FREE Audible Plus: https://amzn.to/3xYzJsR

RASPBERRY PI 4: https://amzn.to/3BC4i9I
RASPBERRY PI PICO START KIT: https://amzn.to/3REvjis
RASPBERRY PI CAMERA V2: https://amzn.to/3QFp90c
ELECTRONICS COMPONENT STARTER KIT: https://amzn.to/3qB23xg
ASSORTED SENSOR KIT: https://amzn.to/3U7M7zV
USB SPEAKER: https://amzn.to/3La4foK
USB 1080P WEBCAM: https://amzn.to/3Lq0OL7

TIMESTAMPS and COMMANDS
0:00 Intro
0:14 Why use a virtual environment?
0:59 What is a virtual environment?

Check python version with python -V
Make a virtual environment: python -m venv env
If you have Python older than 3.3 run: python -m pip install virtualenv
then make the virtual environment: python -m virtualenv env
Look at your site packages: pip list

3:55 Activate your virtual environment
Windows: .\env\Scripts\activate
Mac/Linux: source env/bin/activate
You should see "(env)" at the start of your command line
Do "pip list" to verify your virtual environment is working

5:25 Transferring environments
Look at "pip freeze"
Run: pip freeze "GREATER THAN SYMBOL" requirements.txt
(sorry youtube doesn't let me do the greater than symbol in the description)
Make your new environment
Run: python -m pip install -r requirements.txt

7:55 virtualenv verses venv

8:20 Recap

I hope this helped!


On this page of the site you can watch the video online What is a Virtual Environment in Python? with a duration of hours minute second in good quality, which was uploaded by the user Sam Westby Tech 26 March 2022, share the link with friends and acquaintances, this video has already been watched 6,387 times on youtube and it was liked by 218 viewers. Enjoy your viewing!