Python Virtual Environments - Full Tutorial for Beginners

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

Пікірлер: 58

  • @TechWithTim
    @TechWithTim2 ай бұрын

    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
    @agentm102 ай бұрын

    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 ай бұрын

    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).

  • @JohnS-er7jh
    @JohnS-er7jhКүн бұрын

    Another awesome video. Corey Schafer 's channel and Tech With Tim are my two favorite Python channels, and of course you can learn a lot more then just python. Thanks for posting more great content.

  • @brianhotton2262
    @brianhotton22622 ай бұрын

    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.

  • @casperolsen8147
    @casperolsen81472 ай бұрын

    Your delivery on Python topics are the best on KZread.

  • @Oodle-ox2vf
    @Oodle-ox2vf2 ай бұрын

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

  • @Gndt1
    @Gndt1Ай бұрын

    Excellent video. Clear, concise and informative.

  • @alexis_suarez
    @alexis_suarez2 ай бұрын

    This is exactly what I was looking for, really useful

  • @dezly-macauley
    @dezly-macauley2 ай бұрын

    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.

  • @tokenizedgameplay
    @tokenizedgameplayАй бұрын

    Thanks Tim, you made it look easy

  • @yadhumanikandan7220
    @yadhumanikandan72202 ай бұрын

    Can you do docker tutorial too.

  • @chriskeo392

    @chriskeo392

    2 ай бұрын

    I need that docker compose tutorial asap😅

  • @yadhumanikandan7220

    @yadhumanikandan7220

    2 ай бұрын

    yeaahhhh!!! 😆@@chriskeo392

  • @sw-code6027

    @sw-code6027

    2 ай бұрын

    ​@@chriskeo392 did you found any good tutorial?

  • @mathiaselorm5996
    @mathiaselorm59962 ай бұрын

    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 👍👍👍

  • @JohnColgan.
    @JohnColgan.2 ай бұрын

    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. :)

  • @Al_Miqdad_
    @Al_Miqdad_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 ❤

  • @MiroKrotky
    @MiroKrotky2 ай бұрын

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

  • @markgruic8495
    @markgruic84952 ай бұрын

    Great job

  • @hiasvonminga4948
    @hiasvonminga49482 ай бұрын

    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!

  • @jonasvilks2506
    @jonasvilks25062 ай бұрын

    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?

  • @chinzorigyou
    @chinzorigyouАй бұрын

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

  • @anutarobert3022
    @anutarobert3022Ай бұрын

    TIM you are GOOOD!

  • @johnidouglasmarangon
    @johnidouglasmarangon2 ай бұрын

    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.

  • @Boghost1430
    @Boghost14302 ай бұрын

    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

  • @user-ts9ks8in2n
    @user-ts9ks8in2n2 ай бұрын

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

  • @TechWithTim

    @TechWithTim

    2 ай бұрын

    vent is more common

  • @spacecoder0526
    @spacecoder05262 ай бұрын

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

  • @KumR
    @KumR2 ай бұрын

    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 ай бұрын

    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.

  • @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
    @hasanx831719 күн бұрын

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

  • @bostonmike6912
    @bostonmike6912Ай бұрын

    Make a video on poetry package management for python.

  • @spicyshizz2850
    @spicyshizz28502 ай бұрын

    Do you plan to make ML & AI videos soon?

  • @saurabhparthe1219
    @saurabhparthe12192 ай бұрын

    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.

  • @BillAugersdca
    @BillAugersdca2 ай бұрын

    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.

  • @gamingguy577
    @gamingguy5772 ай бұрын

    Can Davin do backened ?

  • @abdulmobinkarimi6846
    @abdulmobinkarimi68462 ай бұрын

    make a video about DEVIN

  • @pauloclara4764
    @pauloclara47642 ай бұрын

    Whats diference to docker

  • @sandilemasuku2240
    @sandilemasuku22402 ай бұрын

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

  • @kacper2028
    @kacper202828 күн бұрын

    Wait so what actually is in the venv folder?

  • @Mustang_G
    @Mustang_G2 ай бұрын

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

  • @crystyxn
    @crystyxn2 ай бұрын

    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 ай бұрын

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

  • @agentm10

    @agentm10

    2 ай бұрын

    @@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.

  • @pietrovalentinoyannellihan3883
    @pietrovalentinoyannellihan38832 ай бұрын

    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

  • @jabirmustafasulaiman5147
    @jabirmustafasulaiman51472 ай бұрын

    Is your course free

  • @TechWithTim

    @TechWithTim

    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
    @akramazad51372 ай бұрын

    Davin can do this in few minutes

  • @gmailservice9945
    @gmailservice99452 ай бұрын

    excellent tutorial thank you