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

Поделиться
HTML-код
  • Опубликовано: 26 ноя 2024

Комментарии • 529

  • @coreyms
    @coreyms  5 лет назад +298

    In my older virtualenv video, I got a ton of requests to show how to use virtual environments on Windows. I hope this helps!

    • @Violet_Patrick
      @Violet_Patrick 5 лет назад +3

      Hey Corey, thank you as always, i was trying to debug a Python for loop and was not sure if you talk about it anywhere. Also realized that sublime text 3 does not actually feature a python debugger, would appreciate your thoughts on this.

    • @guipa
      @guipa 5 лет назад +2

      Thank you for all your videos. You should do one someday for pipenv!

    • @guipa
      @guipa 5 лет назад +2

      And multiprocessing/multithreading

    • @guipa
      @guipa 5 лет назад +1

      And sockets!

    • @coreyms
      @coreyms  5 лет назад +3

      @@guipa I already have one for Pipenv. You can find that here: ruclips.net/video/zDYL22QNiWk/видео.html

  • @matiasgomez9416
    @matiasgomez9416 5 лет назад +368

    pip list > 2:13
    python -m venv project_env > 2:29
    project_env\Scripts\activate.bat > 3:24
    where python > 3:46
    pip install requests > 4:48
    pip install pytz > 5:00
    pip list >
    pip freeze > 5:47
    --> copy information 'pip freeze'
    --> create requirements.txt > 6:37
    --> paste information there
    deactivate > 7:16
    rmdir project_env /s > 7:33
    >> NEW PROJECT 8:48
    python -m venv my_project\venv > 8:55
    my_project\venv\Scripts\activate.bat
    pip install -r requirements.txt > 9:46
    cd my_project > 10:50
    --> create new file 'script.py'
    deactivate >
    rmdir venv /s >
    python -m venv venv --system-site-packages > 13:30
    venv\Scripts\activate.bat >
    pip list >
    pip install SQLAlchemy
    pip list --local

  • @Capt_X
    @Capt_X 5 лет назад +58

    Corey...You are the Guru of python world..thanks a lot for sharing your knowledge as always!

  • @백영래-u3x
    @백영래-u3x 5 лет назад +6

    Thank you for this tutorial! I couldn't figure out how to use VENV on my own, even though I read a book called " Test Driven Development" because the author explained how to use VENV on mac. Corey, you're the man!

  • @doneenhesse8153
    @doneenhesse8153 5 лет назад +46

    This has been so helpful! My class focused mostly on programming, and so we didn't really understand what we were doing during setup, but your videos make it very clear and easy! Thank you!

  • @SamarHussain1
    @SamarHussain1 Год назад +1

    This is the best venv tutorial that I've ever seen. Its bookmarked in my browser for over 1.5 years now. I get back to it whenever I miss something. Thanks man (y)

  • @kelvinokelvino783
    @kelvinokelvino783 3 года назад

    i was totally confuse and frustrated just before completing the 17 minutes of this video
    honestly i feel really relief now..
    you got a new fan now man.....
    thank you...

  • @ife_jeremiah
    @ife_jeremiah 2 года назад +11

    This is a simple and straight to the point tutorial. Well done man.
    You've just gotten a subscriber.

  • @alex08585
    @alex08585 3 года назад +1

    This video saved me in setting up venv in windows, still relevant in 2021

  • @micahjesse6580
    @micahjesse6580 2 года назад +2

    This is the best video I've seen this year so far!!! I might be exaggerating but you sir have helped me solve a problem I was working on for the last 20+ hrs!

  • @hangfirers
    @hangfirers Год назад

    Thank you so much! I’ve searched and read and tried everything on the net on how to set up venv but this is the only one that worked.

  • @takshvitweets
    @takshvitweets 5 лет назад +13

    This is just perfect. I had been looking to understand venv for quite sometime now, and this clears it all. Great job!!!

  • @ShahZ
    @ShahZ 3 года назад +1

    Thanks @Corey Schafer. trying to follow some Django tutorial on RUclips but just couldn't activate the virtual env, windows would accept the CMD but won't activate the venv :
    Setup: win 10, gitbash, python 3.7
    Create the venv: python -m venv my_dir
    Activate the venv: source my_dir/Scripts/activate
    Stackoverflow to the rescue. Love your work btw thanks from the rest of us.

  • @ronilif
    @ronilif 3 года назад

    Thank you Corey, I almost gave up trying to work with venv, until i saw this brilliant post...

  • @simonolofsson7488
    @simonolofsson7488 5 лет назад +16

    This is exactly what I needed just now for my project which is rapidly growing in complexity. Thanks Corey!

  • @drissaitkassimusic
    @drissaitkassimusic 4 года назад +2

    This guy is a real instructor. Great work a lot of effort there thank you

  • @donnie1581
    @donnie1581 4 года назад +3

    jesus you don't know how much this helped me. All tutorials I've watched were done on Mac haha

  • @nigelemccoy1534
    @nigelemccoy1534 2 года назад

    This guy is the GOAT, simple and easy tutorials! This helps alot!

  • @parthzala9426
    @parthzala9426 4 года назад +1

    Great tutorial! I am a hobbyist programmer, not an expert. I have been learning my self and this really helped.

  • @rVnikov
    @rVnikov 5 лет назад +5

    Yet another video from maestro Schafer that makes difficult subject looks pretty easy.
    Respect!

  • @bryanaguilar402
    @bryanaguilar402 4 года назад +6

    This was great. I was thinking of questions as the video moved along and then you ended up answering them all. Great work Corey.

    • @tagifts
      @tagifts 3 года назад

      He does that doesn't he. One of the most clear videos on venv.

  • @bobfreeedu
    @bobfreeedu 2 года назад

    You are the best I have been like 2hour trying to figure it out , and with you it took like 1min

  • @JSRAumDhyanam
    @JSRAumDhyanam 4 года назад

    Corey, I watched lot of videos about the environment and virtual environment but could not understand. Your explanations technique is the best. Thanks.

  • @onepercentdaily8772
    @onepercentdaily8772 Год назад

    Even after 4 years, it is still a valid a video 😍

  • @ajitkumar15
    @ajitkumar15 3 года назад

    Thank you so much for resolving the issue. other videos on RUclips wasted my time.

  • @X19-x5f
    @X19-x5f 5 лет назад +1

    Pretty much what the rest of the comments say - great video and thanks once again!

  • @ishanpand3y
    @ishanpand3y 4 года назад

    Sir, you're just best.
    If anyone wants to automate the creation of requirements.txt file then just type in this:
    *pip3 freeze > requirements.txt*
    It will automatically save that.

  • @shreyraval3284
    @shreyraval3284 4 года назад

    Most simplest explanation there can ever be! 100000%

  • @ItzSenaCrazy
    @ItzSenaCrazy 5 лет назад +22

    I really needed this video.
    Thanks Corey!!

  • @ayodele_great
    @ayodele_great 5 лет назад +4

    Many thanks for this tutorial. You have saved me from what I spent a whole weekend trying to figure out.

  • @mihaigrigore2136
    @mihaigrigore2136 5 лет назад +4

    Thank you Corey for this excellent video on virtual environments. I needed it. You do not assume anything as known and this is very good, especially for beginners. For me, the best explanation on this topic I found!

  • @VEGETADTX
    @VEGETADTX 4 года назад

    The single most important Python tutorial since Python's existence. Virtual environments are the most effective anti-hair loss treatment ever invented :)

  • @AhmetAnilDindar
    @AhmetAnilDindar 5 лет назад +4

    This is a very good video to learn venv module in short time. I appreciate your work.

  • @pipertripp
    @pipertripp 5 лет назад +2

    Super helpful. Clear, concise, to the point. Thx much, m8.

  • @gburbano92
    @gburbano92 3 года назад

    @ 3:34 my issue was solved thanks for the content!

  • @i3130002
    @i3130002 4 года назад

    Export pip list:
    pip freeze > requirements.txt
    Import pip list:
    pip install -r "requirements.txt path"
    Create Env with pip packages:
    python -m venv "projectName" --system-site-pakages

  • @markettext
    @markettext 3 года назад

    Good video, cleared a lot up. The programming is easier than the setup.

  • @arthurfelde5437
    @arthurfelde5437 4 года назад

    You are talking very fast, but you covered everything important to know. Many Thanks for that

  • @yasirzahid5088
    @yasirzahid5088 2 года назад +1

    in short
    (i am assuming you have activated virtual environment)
    type: pip freeze
    (you will see all requirements)
    copy all to requirements.txt (16:40 observe copying process carefully)
    //(make sure requirements.txt is in project folder)
    type: deactivate
    (venv will be deactivated)
    type: pip install -r .
    equirements.txt
    (all requirements will be installed)
    type:.\venv\Scripts\Activate.ps1
    (activating environment)

  • @isagive
    @isagive 2 года назад

    Thank you Corey, you actually explained away all the questions
    a noob like me came with. Things I just didn't understand and most videos
    skip, I guess cuz its obvious to the creator. Very helpful tutorial 🙏 thank u

  • @soumyajitsarkar2372
    @soumyajitsarkar2372 4 года назад

    This is the best video on the subject of python virtual environment! Thank You .

  • @avivran1198
    @avivran1198 4 года назад +1

    Very good one! Thank buddy. I like your videos. Your attitude and way of passing the stuff to your viewers is just excellent.

  • @pierrelesage1535
    @pierrelesage1535 3 года назад

    Never found a more fitting video to my problem, thanks a lot!!

  • @johnimperial8096
    @johnimperial8096 4 года назад

    Just to add something to this great tutorial. we can dump the result of "pip freeze" into "requirements.txt" file by doing
    pip freeze > requirements.txt
    removing the need to copy the pip freeze results manually.

    • @aka5
      @aka5 4 года назад

      I think he was saying this caused his command prompt to change colour hence why he didn't do it

  • @bonnfranks5488
    @bonnfranks5488 3 года назад

    My man...I've been struggling with this. Great video. Thank you so much.

  • @thomaskirsch2209
    @thomaskirsch2209 3 года назад +1

    Great videos Corey. You are the go to when I am looking to understand something python. Thanks for helping the community!

  • @salarghaffarian4914
    @salarghaffarian4914 3 года назад

    You are the best instructor!

  • @stardevilyn
    @stardevilyn 9 месяцев назад

    This is very well explained and easy to follow. Thanks for the tutorial!

  • @yash9089
    @yash9089 3 года назад +1

    Thank you for this, you are the foundation of whatever i do or develop related to python

  • @francisguchie1973
    @francisguchie1973 Год назад +3

    This video is a simplified as a sip on a cup of coffee thank you so much Corey

  • @Sonali_Dams
    @Sonali_Dams 3 года назад

    Loved the solution finally my problem is solved.. bless you man.

  • @xsandwichxxsandwichx1778
    @xsandwichxxsandwichx1778 2 года назад

    Thx Corey! This video is still helping me out in 2022

  • @p.9227
    @p.9227 5 лет назад +9

    This video really helps me a lot. Hope you'll make more videos like that.

  • @scotttct
    @scotttct 3 года назад

    Thanks Corey for creating this, I think every RUclips turorial uses Mac, and I could not find a decent source for learning Virtual Environments...

  • @pcbekri340
    @pcbekri340 Год назад

    you are awesome i don't have words to describe how helpful this video was thanks alooot man

  • @cm_dev
    @cm_dev 3 года назад

    Your videos are the best. Thanks for sharing your knowledge.

  • @nicolasduque3871
    @nicolasduque3871 4 года назад

    This video was great for me, I'm just learing python for the first time and as a windows user it was easy to follow the steps, congratulations. It would be great if you are able to add the english subtitles in the video because as me that I'm not an english person many other people could watch the video easer reading the subtitles

  • @Quaght
    @Quaght 3 года назад

    This was so helpful and concise. Thank you very much from a Python (heck, programming in general) noob!

  • @jeffskoldberg416
    @jeffskoldberg416 2 года назад

    You're right, is is simple and doesn't have the bells and whistles of pipenv. The one thing I really prefer in pipenv is your pipfile is update automatically. Here, you would have to remember to add something to your requirements.txt after you install it.

  • @daniyarkaisan8387
    @daniyarkaisan8387 3 года назад

    Thank you! That was the best explanation I encountered on RUclips!

  • @shiro3940
    @shiro3940 3 года назад

    I want to confirm that I understand it correctly.
    So the venv module here, is used to create... a virtual environment.
    it's like a copy of python, but one that I can mess around with and don't have to worry about.
    once I'm done with it or don't need it anymore, I can simply delete it like deleting a normal folder.
    whatever I do in the virual environment, doesn't affect the main python installation (/AppData/Local/.../Python).

  • @louism.4980
    @louism.4980 10 месяцев назад

    Thank you so much, love how simple and clear this tutorial is! :)

  • @prateekupadhya1523
    @prateekupadhya1523 Год назад

    Amazing tutorial - No one explains it like you do Corey!

  • @pradhumnsharma5982
    @pradhumnsharma5982 3 года назад

    Awesome and Easily understandable explaination.

  • @astrostudent2302
    @astrostudent2302 4 года назад

    Lovely voice, pace and control

  • @averydrago
    @averydrago 4 года назад +1

    Very helpful and you make it very intuitive, thank you!

  • @MidoriToyota
    @MidoriToyota 4 года назад

    Best tutorial for Virtual Environments!

  • @DanielGarcia-hc1kf
    @DanielGarcia-hc1kf 4 года назад

    To create the enviroment on python 3.8 the command is: py -m venv

  • @Virtualexist
    @Virtualexist 3 года назад

    Best video to understand Virtual Environments Corey the messiah ! UwU

  • @financephofun7090
    @financephofun7090 2 года назад

    Thank you for sharing! saves a ton of time, trying to search for solutions on your own

  • @kannanchandrasekaran3561
    @kannanchandrasekaran3561 5 лет назад +6

    This is helpful Corey, comprehensive and good phase!

  • @The231Flash
    @The231Flash 3 года назад

    If I could like the video 10x I would, thanks bro

  • @ZajoSTi
    @ZajoSTi 4 года назад

    Best venv tutorial hands down. Thank you. Subscribed :)

  • @mjj2u2
    @mjj2u2 3 года назад

    Great job. I found this very helpful.

  • @jackignatev
    @jackignatev 2 года назад

    Incredibly useful! Big thanks for detailed description and instructions

  • @MosharofHossainZitu
    @MosharofHossainZitu 4 года назад +1

    Thanks Corey Schafer, it was a very helpful tutorial!

  • @lamba5945
    @lamba5945 5 лет назад

    Lol. I like Google's algorithms. Today I was looking for "how to launch virtual environment" to use Django and now this is in my recommendations. (Sorry for my bad English and hello from Russia)

    • @FordExplorer-rm6ew
      @FordExplorer-rm6ew 5 лет назад

      I know right.
      They didn't used to have all this info for coding.
      It's the one thing Google actually gets right.
      Which shows they know how to recommend content. (This is significant because normally they suppress content)
      (They normally suppress any good non coding related content like debates bloodsports, shitposting channels etc etc,
      But coding info they've been very good at)

  • @muuzabebe3365
    @muuzabebe3365 3 года назад +1

    you are unique, keep it up !!!!!!!!!!!!!!!!!!!!!!!!!!

  • @rafaelmrtnz
    @rafaelmrtnz Год назад

    Thank you, that was really informative! Clears up questions.

  • @cborrero2000
    @cborrero2000 2 года назад

    Amazing and comprehensive video, Many thanks Corey.

  • @jacobbell1503
    @jacobbell1503 3 года назад

    Well done. Straight to the point.

  • @sameerspl
    @sameerspl 5 лет назад +1

    Awesome Man . You are awesome Corey . Thanks a ton . I love the way you make things simpler .

  • @pedrograngeiro3849
    @pedrograngeiro3849 3 года назад

    Thank you so much. In 2021 this video is really good, but i had changed the second command to "python3 -m venv project_env". Just add the 3 in python.

  • @aliyanpops6424
    @aliyanpops6424 3 года назад

    Thanks sir you're a blessing you're way of explanation is easy and interesting.

  • @jake8217
    @jake8217 4 года назад

    Man, you are just amazing. Very clear explanations. Saved me a lot of trouble.

  • @AegirAexx
    @AegirAexx 4 года назад

    Thank you Corey. All this virtual environment stuff was really confusing regarding how many of them there are. I'm going to stick with the baked in one, venv.

  • @Vivian-ve1qt
    @Vivian-ve1qt 2 года назад

    Very well explained. So grateful for these videos. 🙏

  • @st4willow
    @st4willow 5 лет назад +1

    Thank you so much Corey for making these wonderful videos. They are all easy to understand and follow. I learn so much from them. I will join patreon to contribute to the group. Thank you for all you do!

    • @coreyms
      @coreyms  5 лет назад

      Thanks! That’s a huge help!

  • @marco8060
    @marco8060 4 года назад

    i wish i could give more than one likes to this dude.

  • @robertsampson4000
    @robertsampson4000 4 года назад +1

    Great video. Really good explanation.

  • @MarkJay
    @MarkJay 5 лет назад +2

    Nice video. Conda has been acting weird with pip packages so I've ditched anaconda and gone this way. Minor note, you can leave off the .bat when activating

  • @chetansoni8620
    @chetansoni8620 4 года назад +1

    Thanks a lot for sharing this informative information beautifully

  • @t.w.freiburg6125
    @t.w.freiburg6125 5 лет назад

    Great. Finally even me understood this stuff.
    I'd have a question. When I use venv and when I should use docker?
    A tutorial of this kind for docker would be awesome. Thanks a lot.

  • @asoahmadzade4305
    @asoahmadzade4305 3 года назад +1

    Excellent explanation

  • @mistwire
    @mistwire 5 лет назад +1

    Thanks for posting this, now I finally get how to use it in Windows :-)

  • @pready5082
    @pready5082 4 года назад +1

    Loved it! So detailed and clear

  • @em2350
    @em2350 3 года назад

    It is possible to just add the requirements.txt by using the pip freeze > requirements.txt command without creating the file ourselves
    Great video

  • @andreyminin7259
    @andreyminin7259 4 года назад

    This video is PERFECT!!! Can you make all youtube tutorials, please? :) Thank you!!

  • @fillipemadureira9210
    @fillipemadureira9210 5 лет назад +8

    Corey, I tried running venv but I got this error:
    Error: Command '['C:\\Users\\Fillipe Madureira\\Desktop\\project_env\\Scripts\\python.exe', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 101.
    Can't find what it means... Any idea?
    Thanks for the help and all the tutorials, man. They have been incredibly useful to a newcomer.

  • @tullymars420
    @tullymars420 3 года назад

    Fantastic video!! I am so grateful for this content!! I fell like I just made a leap in my coding journey!! Thank you so much!!!