Python Tutorial: VENV (Mac & Linux) - How to Use Virtual Environments with the Built-In venv Module

In this Python Programming Tutorial, we will be learning how to use virtual environments on the Mac and Linux operating systems with the built-in venv module. We will learn how to create them, activate them, remove them, and much more. Let's get started...
VENV (Windows) - • Python Tutorial: VENV ...
✅ Support My Channel Through Patreon:
/ coreyms
✅ Become a Channel Member:
/ @coreyms
✅ One-Time Contribution Through PayPal:
goo.gl/649HFY
✅ Cryptocurrency Donations:
Bitcoin Wallet - 3MPH8oY2EAgbLVy7RBMinwcBntggi7qeG3
Ethereum Wallet - 0x151649418616068fB46C3598083817101d3bCD33
Litecoin Wallet - MPvEBY5fxGkmPQgocfJbxP6EmTo5UUXMot
✅ Corey's Public Amazon Wishlist
a.co/inIyro1
✅ Equipment I Use and Books I Recommend:
www.amazon.com/shop/coreyschafer
▶️ You Can Find Me On:
My Website - coreyms.com/
My Second Channel - / coreymschafer
Facebook - / coreymschafer
Twitter - / coreymschafer
Instagram - / coreymschafer
#Python #venv

Пікірлер: 236

  • @Rocorama1
    @Rocorama15 жыл бұрын

    You've gotta show this guy the love as he always explains things in such simple terms and then gives you a little extra that you weren't expecting! Thank you sir for all the time you invest to give us great content!

  • @coreyms

    @coreyms

    5 жыл бұрын

    Thanks!

  • @kipronoelijahkoech4630
    @kipronoelijahkoech46304 жыл бұрын

    You are just too great. Nowadays I search KZread with your name I be like "virtual environment in Python Corey Schafer" .

  • @ruixue6955
    @ruixue69554 жыл бұрын

    0:48 why virtual environment to have a space where we can install packages specific to a certain project 0:57 example for updating from Django 1 to Django 2 1:22 each project should have its own packages separate from each other 1:34 demo: need *Python 3.3 or higher* 2:05 pip3 list 2:51 create a new virtual environment - 2:57 *python3 -m venv project_env* (project_env is the name of the project to be initialized) 3:42 activate the created virtual environment - 3:45 *source* project_env/bin/activate 5:34 if other wants to export the packages that are used 5:39 *requirement.txt* 5:56 *pip freeze* 6:25 in Linux: *pip freeze > requirements.txt* 6:55 deactivate the project *7:43** normal practice of using venv* 8:24 use of the created requirements.txt 8:35 *pip install -r requirements.txt* 9:04 one thing to mention: *it is common to put virtual environment inside your project folder, but you don't want to put project files into your virtual environment* 9:29 10:01 you shouldn't commit your virtual environment to your source control 10:16 what should be committed in version control: your requirements.txt 10:38 how to create an environment with access to system-packages 11:29 --system-site-packages 12:08 the additional packages installed in this environment won't affect the system packages 12:35 pip list --local

  • @lofi_Insomnia_

    @lofi_Insomnia_

    3 жыл бұрын

    this is awesome

  • @viviantomlinson

    @viviantomlinson

    3 жыл бұрын

    thank you!!

  • @rafaelalvesduarte4928
    @rafaelalvesduarte49284 жыл бұрын

    Simple, direct and well explained. Thanks man, this helped me!

  • @pavelow36
    @pavelow364 жыл бұрын

    been to numerous pages, wikis, stackoverflows and only got confused snippets of virtual environments. Watched your video and my brain got opened and clarity shone inside... magnifico!

  • @joelprestonsmith
    @joelprestonsmith Жыл бұрын

    I love how simple and straightforward this video is. Whenever I want to learn something new about Python, I first check to see if you've covered it.

  • @abraraltaflone
    @abraraltaflone3 жыл бұрын

    I was so much confused about the environment thing earlier but after watching the video you made so easy for me to understand. You're great!

  • @Ben-kz2km
    @Ben-kz2km4 жыл бұрын

    These virtual environments are a really clever way to not run into problems when you have different projects with different requirements. I love it!

  • @alexandrostsagkaropoulos
    @alexandrostsagkaropoulos11 ай бұрын

    So simple, yet elegant and concise explanation of something I just now comprehended completely. Congrats Corey, you are a phenomenal teacher!

  • @sheesh_kebab
    @sheesh_kebab4 жыл бұрын

    This video explains everything...and then goes beyond! Loved it.

  • @leedavies6779
    @leedavies67795 жыл бұрын

    concise, clear and perfectly delivered. I will be using this a lot from now on.

  • @0x007A
    @0x007A3 жыл бұрын

    The introduction to venv that I was seeking - concise yet complete.

  • @rudiklein
    @rudiklein5 жыл бұрын

    You're a great teacher. All of your video's are clear and interesting. Especially for an advanced noob like me.

  • @AdeAderinto
    @AdeAderinto4 жыл бұрын

    Simple and straight to the point. Thank you for this. Much appreciated.

  • @souravkaranjai6428
    @souravkaranjai64283 жыл бұрын

    Thank you for such an amazing video, You seem to know exactly what your student has in mind and what problems he is trying to solve while watching your videos.

  • @loudencm
    @loudencm3 жыл бұрын

    Corey...thank you...I have just started the road to data science and one thing I have never had a good simple explain action if were basics of setting up environments without much hassle. I followed this like ABC. I understand what is happening, what to do, how to undo it and how to pass it on.

  • @ichbrauchmehrkaffee5785
    @ichbrauchmehrkaffee5785 Жыл бұрын

    thank you for clearling up, not only how it's done, but also how the convention is

  • @Naton
    @Naton5 жыл бұрын

    Thanks! I finally got my head around venv...

  • @Ausare911
    @Ausare911 Жыл бұрын

    On all of your videos (that I've watched) you fill knowledge gaps perfectly.

  • @matiascoca
    @matiascoca5 жыл бұрын

    Great videos Corey. Clear and perfect explanation.

  • @irisx3375
    @irisx33754 жыл бұрын

    It's like whatever my problems are, you have a solution or tutorial. Thanks soooo much!

  • @nicklansbury3166
    @nicklansbury31664 жыл бұрын

    Thanks for the helpful explanation Corey. For those folks (like me) using the fish shell, at around the 3:50 mark you'll need to enter *source py3env/bin/**activate.fish* in the terminal otherwise you'll most likely get an error like this: project_env/bin/activate (line 74): Missing end to balance this if statement if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then ^ from sourcing file project_env/bin/activate called on standard input source: Error while reading file 'project_env/bin/activate'

  • @sakhawatali9481
    @sakhawatali94813 жыл бұрын

    Great tutorial thanks. Short and informative. Below are my notes. 1. Create a seprate folder for venv data inside the project source 2. Create virtual environment -python3 -m venv {path/folder} $ python3 -m venv venv 3. Create virtual environment which have access to system packages $ python3 -m venv venv --system-site-packages 4. Activate virtual environment -source {folder}/bin/activate $ source venv/bin/activate 5. Check if venv is activated $ which python 6. List installed package pip list 7. List packages installed in venv $ pip freeze 8. Export required package to requirment.txt pip freeze > requirment.txt 9. Exit venv deactivate 10. Install packages from requirment.txt in venv $ pip install -r requirement.txt

  • @suhasramesh2773
    @suhasramesh27733 жыл бұрын

    Very clear explanation and covers only what is needed, Thanks for this crisp and clear video clip!

  • @st3114rr
    @st3114rr3 жыл бұрын

    This was so clear, concise, and comprehensive. Thanks so so much!

  • @xxlilbabeexx1
    @xxlilbabeexx18 ай бұрын

    This was exactly what I was looking for. THANK YOU! You're a great teacher.

  • @Ko0lHaNDLuKex
    @Ko0lHaNDLuKex3 жыл бұрын

    As someone coming to Python from another programming language, this was very helpful!

  • @lauradillon7173
    @lauradillon71734 жыл бұрын

    Excellent video to explain the basics of virtual environments! Thank you!!

  • @kodiak4777
    @kodiak47773 жыл бұрын

    Incredible videos. Kept answering my questions as he went. Keep up the good work.

  • @NormanBaatz
    @NormanBaatz Жыл бұрын

    Best video on venv that I found of the six I watched (and didn't even care to finish watching in some cases).

  • @Ghasakable
    @Ghasakable5 жыл бұрын

    Man! Your channel is awesome Keep up with the awesome work

  • @VictorOlet
    @VictorOlet4 жыл бұрын

    7:22 Creating a new virtual environment (Best practice) 4:28 If you need to use a different version of python 5:40 Exporting packages from your environment with requirements.txt file 8:25 Creating a virtual environment from a requirements.txt file 10:30 Deactivating environment 11:00 Creating a virtual environment containing all system packages 12:35 Listing packages you've installed within the environment (not system packages)

  • @omarcruz6326
    @omarcruz63263 жыл бұрын

    Dear Sir. Thanks for the great work !!! I was looking for a env tutorial for Mac and this is exactly what I found here !!! Great job. I give like and ... subscribe ! Greetings from Belgium.

  • @charlesbovalis6591
    @charlesbovalis65914 жыл бұрын

    Awesome - much simpler than pipenv ... Thank you for posting that video.

  • @RickoDeSea
    @RickoDeSea2 жыл бұрын

    Thank you. I learned Python Virtual Environment Quickly

  • @domleonhardt7943
    @domleonhardt79433 жыл бұрын

    @corey shafer thanks for the great videos and sharing you knowledge with us. its nice to watch an informative video from someone who speaks clearly;y and is professional and to the point. THANK YOU

  • @twowheelsgood28
    @twowheelsgood282 жыл бұрын

    Great job Corey. I really appreciate the detailed tutorial.

  • @prabhathkota107
    @prabhathkota1075 жыл бұрын

    -system-site-packages was a good tip 👍

  • @scottchristesen2660
    @scottchristesen26602 жыл бұрын

    Exactly what I was looking for. Thank you!

  • @daegudude1048
    @daegudude10485 жыл бұрын

    Always appreciate your video Corey, Thanks :)

  • @fvgoya
    @fvgoya5 жыл бұрын

    Your videos are Awesome! Thanks for sharing your knowledge.

  • @karthickchandrasekaran7284
    @karthickchandrasekaran72842 ай бұрын

    Really helped me understand the importance of virtual environment

  • @jassrajput890
    @jassrajput8903 жыл бұрын

    this is very helpful. thanks very much. i was puzzled from last 4 days OMG. thanks again...

  • @MrKalindro
    @MrKalindro3 жыл бұрын

    Yo dude this is like the best guide in this topic

  • @ignacio2921
    @ignacio29212 жыл бұрын

    Couldn't have been explained better, thanks!

  • @edwardwong654
    @edwardwong654 Жыл бұрын

    I had to watch this like at least 3 times, probably more. But Corey is still the best. If I am not going to understand it with Corey, then it was not meant to be. But I definitely got a little more each time.

  • @RohanKumar-vx5sb
    @RohanKumar-vx5sb Жыл бұрын

    pretty good idea? bro gotta hand it to you. so clarifying illustrations of venv. thank you for another great tut

  • @armena2866
    @armena28664 жыл бұрын

    Super thorough! Thank you

  • @paulliu6057
    @paulliu6057 Жыл бұрын

    You explained so clearly! Thank you!

  • @calvary1808farm
    @calvary1808farm4 жыл бұрын

    Just what I needed! Thanks!

  • @ighsight
    @ighsight2 жыл бұрын

    Right on time. I usually do Python work in Lambda/Cloud Functions environments so my understanding of setting up projects on the desktop is lacking. I always struggle with setting up projects and getting virtual environments working when I have to code the traditional way. The MacOS transition to the z shell has made it worse. Luckily Corey is my Python guru, problem solved. This is the number one Python channel on KZread.

  • @timblichfedlt3984
    @timblichfedlt39842 жыл бұрын

    Still works - virtual enviroments can be pretty difficult for beginners, thanks for explaining so detailed

  • @uberacyjunior3613
    @uberacyjunior36134 жыл бұрын

    Thank you. Very well explained!

  • @lotussymphony
    @lotussymphony3 жыл бұрын

    Thanks for the video, as always is explained perfectly!

  • @zolongOne
    @zolongOne5 жыл бұрын

    Thanks for this awesome tutorial. cheers!

  • @KentBui
    @KentBui3 ай бұрын

    Amazing video, straight to the point

  • @piyushramnani1014
    @piyushramnani10142 жыл бұрын

    Such a life-saver video. Thanks a lot man

  • @einarpersson8257
    @einarpersson82573 жыл бұрын

    Super clear explanation!

  • @snehithtampa7106
    @snehithtampa71063 жыл бұрын

    This guy is the dopest guy and I love his videos.

  • @vamekhbasharuli4585
    @vamekhbasharuli45852 жыл бұрын

    This video helped me so much, thanks!

  • @ritheshjarvis4177
    @ritheshjarvis41774 жыл бұрын

    Super. What exactly is needed.

  • @wakanayt
    @wakanayt3 жыл бұрын

    Thanks, Corey! Very nicely done!

  • @gorg212
    @gorg2122 жыл бұрын

    Very clear explanation! Thanks!

  • @gyan277
    @gyan277 Жыл бұрын

    THANK YOU SIR! it really helped me out i was trying for very long time

  • @westCOpaintball
    @westCOpaintball4 жыл бұрын

    Super helpful, Thank you!

  • @winstonyeung1461
    @winstonyeung14612 ай бұрын

    Thank you so much. Very clear explanation.

  • @FrancisDivine
    @FrancisDivine5 жыл бұрын

    Thank you Mr CoreyMS

  • @MawaMaverick
    @MawaMaverick3 жыл бұрын

    Wow. Genius instructor.

  • @user-ko5yr9mo6d
    @user-ko5yr9mo6d3 жыл бұрын

    thanks very much for the simplest explanation !

  • @oselokaiweka6563
    @oselokaiweka6563 Жыл бұрын

    Honestly, Corey is a life saver!

  • @Chuukwudi
    @Chuukwudi3 жыл бұрын

    Thanks man! I love you. You just saved me.

  • @aV5d9nlUBQ9
    @aV5d9nlUBQ92 ай бұрын

    Very helpful. Thanks, man!

  • @lofi_Insomnia_
    @lofi_Insomnia_3 жыл бұрын

    As a newbie I'm super frustrated by the whole python setup thing cuz Mac has 2 versions of python. It drove me nuts and I found your video -- THANK YOU

  • @arturocampos1879
    @arturocampos18794 жыл бұрын

    Great explanation skills. Thanks!

  • @godnyx117
    @godnyx1173 жыл бұрын

    Thanks a lot man! That video was amazing!!

  • @santosharakere
    @santosharakere3 жыл бұрын

    Excellent demo. Thanks.

  • @nathansonic
    @nathansonic4 жыл бұрын

    Man alive! This is useful

  • @tkadado
    @tkadado Жыл бұрын

    thanks for the best explanation I ever seen

  • @kiwiboy8492
    @kiwiboy84924 жыл бұрын

    Thanks, very helpful stuff...

  • @webuilt_america_period5062
    @webuilt_america_period50624 жыл бұрын

    This was super helpful

  • @Noah-gp4ml
    @Noah-gp4ml5 жыл бұрын

    Brilliant! Thanks!!

  • @pradeepj8266
    @pradeepj82664 жыл бұрын

    You are great thalaiva...😎

  • @acrospidey
    @acrospidey3 жыл бұрын

    So clear. Thank you.

  • @heinrichhelmbold419
    @heinrichhelmbold4196 ай бұрын

    Best tutorial I have seen to date regarding virtual environments, thank you! Unfortunately the wheels keep falling off 😜 Installing libraries I constantly get : "ERROR: Could not build wheels for X" With Linux it's a wormhole of issues and errors... find a solution like virtual environments for one problem, and Linux will open a door to a list of new ones 🤣😂

  • @raffaelloringue
    @raffaelloringue Жыл бұрын

    great explanation! thanks a lot!

  • @easy_tech_explained
    @easy_tech_explained5 ай бұрын

    Great tutorial!

  • @bigdaddyped
    @bigdaddyped3 жыл бұрын

    amazing tutorial thank you!

  • @JohnDoe-he6yc
    @JohnDoe-he6yc4 жыл бұрын

    great video. thanks!!

  • @dalmirog
    @dalmirog3 жыл бұрын

    Love your videos, Mate.

  • @fabianhaglund5792
    @fabianhaglund57923 жыл бұрын

    Clarity! Thank you

  • @yesmanforever1002
    @yesmanforever10023 жыл бұрын

    great as always. thank you!

  • @fonzjedelarosa7587
    @fonzjedelarosa75874 жыл бұрын

    Great video, thanks!

  • @bromountafaik4251
    @bromountafaik42513 жыл бұрын

    Perfect... Thank you :)

  • @WilliamMastrocola
    @WilliamMastrocola2 ай бұрын

    Great Video!

  • @MohammadaliAbbasbeygi
    @MohammadaliAbbasbeygi Жыл бұрын

    crystal clear!

  • @DEADPODVAL
    @DEADPODVAL2 жыл бұрын

    Very useful even for people with low knowledge at english) thx 🤙

  • @mdshakilzaman4439
    @mdshakilzaman44392 жыл бұрын

    very helpful!

  • @fagunraythatha5601
    @fagunraythatha56012 жыл бұрын

    Thank you sir. 👍

  • @PerryBattles
    @PerryBattles9 ай бұрын

    Thank you sir!

  • @guilhemescudero9114
    @guilhemescudero91143 жыл бұрын

    Thanks a lot!