Python Virtual Environments - Full Tutorial for Beginners

Поделиться
HTML-код
  • Опубликовано: 4 июн 2024
  • In this video, I will show you step by step how to create a virtual environment in Python. A virtual environment is a self-contained location that enables you to maintain separate and isolated environments for your python projects. This isolation allows you to manage dependencies, versions, and packages without conflicts across different projects.
    If you want to land a developer job: techwithtim.net/dev
    Skool community for free resources: www.skool.com/software-develo...
    Discord server: / discord
    ⏳ Timestamps ⏳
    00:00 | What Are Virtual Environments?
    00:47 | Creating a Virtual Environment
    03:17 | Installing Packages
    04:29 | Saving Dependencies
    05:25 | Example Work Flow
    07:07 | Virtual Environment Tips
    Hashtags
    #TechWithTim
    #PythonVirtualEnvironments
    #PythonProgramming
    #CodingTips

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

  • @TechWithTim
    @TechWithTim  2 месяца назад +2

    If you want to land a software developer role check out my program with CourseCareers: techwithtim.net/dev

    • @pietrovalentinoyannellihan3883
      @pietrovalentinoyannellihan3883 2 месяца назад

      Hello, i followed your instructions In the video to deploy a flask app in Ubuntu but It didnt work, It shows me the 403 forbidden error, im using plesk, does that Matter?

    • @pietrovalentinoyannellihan3883
      @pietrovalentinoyannellihan3883 2 месяца назад

      I already located the correct files with cd

  • @agentm10
    @agentm10 2 месяца назад +49

    One small comment, venv folders are usually named .venv so that they are hidden, and they also should be part of your git ignore if you put them in the same folder as your .py files. I usually have the .venv folder a level up from the .git directory, so that there is no issue with commits if you forget to put them in .gitignore. Fantastic video as usual!

  • @Helli__
    @Helli__ 2 месяца назад +4

    Great video!
    As a Python beginner myself, I think virtual environments should be the first thing to learn after the basics. Even if you're just messing around with some package you're trying out, it makes it so much easier to keep your projects organized.
    It also helps with learning further packages etc.. Want to learn Flask? Just make a new environment for it, keeping everything together and contained, without cluttering your Python installation(s).

  • @brianhotton2262
    @brianhotton2262 2 месяца назад +2

    Thanks for the great video. I was just learning about virtual environments via some python training I’m taking at work. We are slowly trying to migrate from being a SAS programming shop to using python to code. After watching your video, I learned some additional details that weren’t covered in that training. Got to add some of what you said into my class note. Appreciate the content you’re making. I’ve seen a few of your other videos and they’re always very clear and informative. Keep up the great work.

  • @dezly-macauley
    @dezly-macauley 2 месяца назад +5

    Great video TIm! I honestly think this is the first thing that beginners should learn before even writing their first "Hello world".
    Knowing the best practice of how to correctly setup a project in programming language will reduce future headaches, and allow one to focus on writing code.

  • @casperolsen8147
    @casperolsen8147 2 месяца назад

    Your delivery on Python topics are the best on RUclips.

  • @Oodle-ox2vf
    @Oodle-ox2vf 2 месяца назад

    Good video, not too slow, stayed on topic, works for me. 🙂

  • @Gndt1
    @Gndt1 Месяц назад

    Excellent video. Clear, concise and informative.

  • @alexis_suarez
    @alexis_suarez 2 месяца назад

    This is exactly what I was looking for, really useful

  • @Al_Miqdad_
    @Al_Miqdad_ 2 месяца назад +2

    thanks that was very helpful
    I was diving in this in the last days 😂
    do more videos
    May Allah guide you to his path ❤

  • @mathiaselorm5996
    @mathiaselorm5996 2 месяца назад

    As beginner, after learning python basics, virtual environment is the next thing to learn. It will help you when start learning Django or Flask frameworks. Great video 👍👍👍

  • @tokenizedgameplay
    @tokenizedgameplay Месяц назад

    Thanks Tim, you made it look easy

  • @MiroKrotky
    @MiroKrotky 2 месяца назад

    Thank you i had a slight mish-mash in my head about this from multiple tutorials

  • @JohnColgan.
    @JohnColgan. 2 месяца назад +1

    Back in CPM days, PIP was acronym for Peripheral Interchange Program. Used for copting files to another drive or device

    • @311DaveR
      @311DaveR 2 месяца назад

      Yep - I used a Z80 processor board on my Apple 2. It brings back memories as well. :)

  • @anutarobert3022
    @anutarobert3022 Месяц назад

    TIM you are GOOOD!

  • @yadhumanikandan7220
    @yadhumanikandan7220 2 месяца назад +11

    Can you do docker tutorial too.

    • @chriskeo392
      @chriskeo392 2 месяца назад +1

      I need that docker compose tutorial asap😅

    • @yadhumanikandan7220
      @yadhumanikandan7220 2 месяца назад

      yeaahhhh!!! 😆@@chriskeo392

    • @sw-code6027
      @sw-code6027 2 месяца назад

      ​@@chriskeo392 did you found any good tutorial?

  • @chinzorigyou
    @chinzorigyou Месяц назад

    Thanks bro. I wonder why this kind of Python related tutorials rare?

  • @jonasvilks2506
    @jonasvilks2506 2 месяца назад

    Hi. Thanks a lot! How to use multiple versions of python on one machine? For some projects I need python 3.10 and for some 3.12. Do you recommend to use conda for this scenario or just install several version in OS and use python venv?

  • @markgruic8495
    @markgruic8495 2 месяца назад

    Great job

  • @hiasvonminga4948
    @hiasvonminga4948 2 месяца назад

    Hi Tim, again a very tutorial, thank you!
    I am really with you - anybody who can benefit from this tutorial probably should stick with venv because it is just there.
    It would be interesting for me, how the different tools relate and differ. I know that anaconda is oriented towards data science… but what does that actually mean? Anything I can do in anaconda I can’t do with venv?
    Another question: how do vscode and venv interact? A tutorial how to use environments in vscode and how to use the environment once programming is done.
    Also, how to handle the environment when I want to pull a project from git? Do I have to use the same tool the maintainer used to recreate the project‘s environment or can I still rely on venv?
    Thanks for your work, it is a very nice display for your paid course!

  • @johnidouglasmarangon
    @johnidouglasmarangon 2 месяца назад

    Nowadays it is difficult to work without virtual environments especially if you work on more than one Project at the same time.
    I like using pyenv because I can easily install new versions of Python and create or remove envs . pyenv has an interesting set of CLI commands.

  • @user-ts9ks8in2n
    @user-ts9ks8in2n 2 месяца назад +1

    Holy Tim!, thanks for that.
    Is venv the standard or the conda environment?

  • @Boghost1430
    @Boghost1430 2 месяца назад

    Hello Tim, I've started to use Zed however virtual environments are not as easy to use as in vscode and even after looking through zed's docs i wasn't able to solve the issue, do you have any advice pls

  • @KumR
    @KumR 2 месяца назад +1

    I always had one question Tim. Hope you can clarify. Lets say I create two virtual environments A and B. I do a pip on both and install libraries like Numpy, Pandas, TF, sklearn on both A and B, will that not occupy disk space? Does that mean for every project we do locally, the disk space gets consumed not just for code but these duplicate libraries too ? Is there an option to share a library between two virtual environments (if same version is needed) ? Please clarify

    • @beotiger
      @beotiger 2 месяца назад +1

      Yes, every project you create in venv occupies its own disk space. And no, there is no such option to share same libraries between venvs for it makes no sense. You create venv to be isolated from other venvs so you should not and must not share any libraries berween them.

  • @spacecoder0526
    @spacecoder0526 2 месяца назад

    Can you make tutorial of deploying fast api or any python api projects including virtual environment with docker?

  • @cadetaylor429
    @cadetaylor429 Месяц назад

    Quick question - after creating a virtual environment, will my 'import' statements in my code automatically import the versions of the package that are installed in my virtual environment? Because I have some packages installed globally and in the virtual environment - I'm curious which version will get precedent. Also, is it entirely bad practice to install any packages globally? Should I uninstall all globally installed packages and only use virtual environments? Thanks!

  • @hasanx8317
    @hasanx8317 18 дней назад

    We also need to ignore the venv directory in the git repo right?

  • @bostonmike6912
    @bostonmike6912 Месяц назад

    Make a video on poetry package management for python.

  • @saurabhparthe1219
    @saurabhparthe1219 2 месяца назад

    sir your videos are very nice
    can you make a project on iron man jarvis.

  • @AmodeusR
    @AmodeusR Месяц назад

    For me, using windows with bash, I need to run source env/Scripts/Activate to activate the virtual env.

  • @gamingguy577
    @gamingguy577 2 месяца назад

    Can Davin do backened ?

  • @abdulmobinkarimi6846
    @abdulmobinkarimi6846 2 месяца назад

    make a video about DEVIN

  • @pauloclara4764
    @pauloclara4764 2 месяца назад

    Whats diference to docker

  • @spicyshizz2850
    @spicyshizz2850 2 месяца назад

    Do you plan to make ML & AI videos soon?

  • @BillAugersdca
    @BillAugersdca 2 месяца назад

    When you show the four common choices for virtual environments at 1:31, you seem to equate virtualenv with venv as the images display on screen. Beginners should understand that virtualenv is a third-party tool.

  • @kacper2028
    @kacper2028 27 дней назад

    Wait so what actually is in the venv folder?

  • @sandilemasuku2240
    @sandilemasuku2240 2 месяца назад

    I believe your are able to get a job at c.i.a or m.k 7 agency.

  • @pietrovalentinoyannellihan3883
    @pietrovalentinoyannellihan3883 2 месяца назад

    hello, i followed your instructions in your video to deploy a flask app in ubuntu, but it shows me the error 403 forbidden, so i need to know, your tutorial doesnt work if you are using plesk?, i already located the files with cd and made the arrengements with the wsgi file

    • @pietrovalentinoyannellihan3883
      @pietrovalentinoyannellihan3883 2 месяца назад

      Im sorry for putting the comment here but i think IS more likely to receive help if the comment IS in a recent video

  • @crystyxn
    @crystyxn 2 месяца назад +1

    I thought -r stands for recursive

    • @agentm10
      @agentm10 2 месяца назад

      clearly not. Tim is very explicitly saying that -r is for "install fRom a file", lol.

    • @crystyxn
      @crystyxn 2 месяца назад +1

      @@agentm10 yeah, thats why I commented that. Turns out the -r actually comes from "requirements".

    • @agentm10
      @agentm10 2 месяца назад +1

      @@crystyxn yup, -r FILENAME is the same as --requirement=FILENAME. Although recursive also makes sense as you have to go through all the entries in the file.

  • @Mustang_G
    @Mustang_G 2 месяца назад

    I always thought you just opened VS code and open new file.

  • @jabirmustafasulaiman5147
    @jabirmustafasulaiman5147 2 месяца назад

    Is your course free

    • @TechWithTim
      @TechWithTim  2 месяца назад +2

      There is a free introductory course that is about 1.5 hours long that you can watch before deciding on the full program

    • @vetriselvan9807
      @vetriselvan9807 2 месяца назад

      Nothing free in this world

  • @akramazad5137
    @akramazad5137 2 месяца назад +1

    Davin can do this in few minutes

  • @gmailservice9945
    @gmailservice9945 2 месяца назад

    excellent tutorial thank you