Python Virtual Environments & The Facts of Life

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

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

  • @BobbyHill-d3f
    @BobbyHill-d3f День назад

    Thank you.

  • @ImCalledtheSentinel
    @ImCalledtheSentinel 10 месяцев назад

    Thoroughly enjoyed this and created my virtual environment. Thanks Bryan

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

    Thank you for making this video. I just learned why these are important the hard way when I updated matplotlib and some library I was just experimenting with and completely broke my scripts. Now I have some steps to take to start using these.

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

      Yep. But when you learn the hard way, you remember. Thanks

  • @dietmarb6833
    @dietmarb6833 3 месяца назад

    Thanks for helping lift the fog!

  • @dietmarb6833
    @dietmarb6833 3 месяца назад

    Hi Bryan, I am still struggling with this virtual environment concept. Do you create a virtual env for each new dependency? For instance would I need to create a VE for installing "Requests" to call APIs, another one for matplotlib, one for django, and so on? If so, what's the best way to organize the various VEs? I am on Arch Linux. Thanks for your help.

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

      Yeah. Its really a convenience for developing a project. Say you want to build a Django App in Python. First you create a virtual environment to track all the pip installs you do. It saves them to a Requirements.txt file. The installed packages do NOT go to your global default Python folder. They just go to the project folder, i.e. for the app you are developing. When you activate the virtual env, the packages in the requirements.txt file are loaded. When you want to deploy the app somewhere, you can just provide the requirements.txt file so all the required packages and dependencies are loaded there. You can have different python packages and versions in different projects this way. Python projects typically requires many packages with dependencies which would be almost impossible to track manually. virtual env are there to solve this problem. Make sense?

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

    great stuff Bryan! I have seen in the past using requirements file, how does that come into play with venv or does it come into play at all? thanks!

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

      The same way you can install a single package using "pip install " you can install all you dependencies using "pip install -r ".
      And if you work properly (as tought by Bryan :P ), you run the pip install command while you are in your virtual environment.

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

      I do discuss this in the video.