title
Python Tutorial: How I Manage Multiple Projects, Virtual Environments, and Environment Variables

description
In this Python Programming Tutorial, I will be showing how I personally manage multiple projects, virtual environments, and environment variables. If you have ever worked on multiple projects, you probably know that it can be a hassle to keep all of your dependencies and project information separate. The strategy I have adopted over the years allows me to easily separate out my environments in such a way that they can be easily exported, activated, and also automatically activate the correct environment variables. Let's get started... The workflow I follow: https://conda.io/docs/user-guide/tasks/manage-environments.html Anaconda Intro Video: https://youtu.be/YJC6ldI3hWk The original conda_auto_env code I modified can be found here: https://github.com/chdoig/conda-auto-env/blob/master/conda_auto_env.sh My modified version of conda_auto_env: https://github.com/CoreyMSchafer/code_snippets/blob/master/conda_auto_env.sh ✅ Support My Channel Through Patreon: https://www.patreon.com/coreyms ✅ Become a Channel Member: https://www.youtube.com/channel/UCCezIgC97PvUuR4_gbFUs5g/join ✅ One-Time Contribution Through PayPal: https://goo.gl/649HFY ✅ Cryptocurrency Donations: Bitcoin Wallet - 3MPH8oY2EAgbLVy7RBMinwcBntggi7qeG3 Ethereum Wallet - 0x151649418616068fB46C3598083817101d3bCD33 Litecoin Wallet - MPvEBY5fxGkmPQgocfJbxP6EmTo5UUXMot ✅ Corey's Public Amazon Wishlist http://a.co/inIyro1 ✅ Equipment I Use and Books I Recommend: https://www.amazon.com/shop/coreyschafer ▶️ You Can Find Me On: My Website - http://coreyms.com/ My Second Channel - https://www.youtube.com/c/coreymschafer Facebook - https://www.facebook.com/CoreyMSchafer Twitter - https://twitter.com/CoreyMSchafer Instagram - https://www.instagram.com/coreymschafer/ #Python

detail
{'title': 'Python Tutorial: How I Manage Multiple Projects, Virtual Environments, and Environment Variables', 'heatmap': [{'end': 218.311, 'start': 182.31, 'weight': 0.716}, {'end': 441.536, 'start': 422.259, 'weight': 0.756}], 'summary': 'Tutorial covers managing multiple projects, virtual environments, and environment variables using anaconda and conda, including creating environment.yaml files, replicating exact environments, managing secure data access, and demonstrating activation and management of python environments, databases, and virtual environments for different projects.', 'chapters': [{'end': 225.197, 'segs': [{'end': 29.977, 'src': 'embed', 'start': 0.209, 'weight': 2, 'content': [{'end': 1.229, 'text': "Hey there, how's it going everybody?", 'start': 0.209, 'duration': 1.02}, {'end': 7.45, 'text': "In this video, I'm going to walk through how I personally handle multiple projects, virtual environments and environment variables.", 'start': 1.609, 'duration': 5.841}, {'end': 13.472, 'text': "Now, when you're working on multiple projects at once, it's easy to get your packages and dependencies mixed up,", 'start': 7.831, 'duration': 5.641}, {'end': 16.332, 'text': "and also it's hard to keep track of virtual environments,", 'start': 13.472, 'duration': 2.86}, {'end': 20.633, 'text': 'and also you might have environment variables that are overriding each other and things like that.', 'start': 16.332, 'duration': 4.301}, {'end': 24.894, 'text': "So in this video, I'll show you how I keep all of these separate and easy to work with.", 'start': 21.053, 'duration': 3.841}, {'end': 29.977, 'text': 'So before I get started, I just want to point out that this is how I personally manage these projects and environments.', 'start': 25.214, 'duration': 4.763}], 'summary': 'Managing multiple projects, virtual environments, and environment variables to avoid mix-ups and conflicts.', 'duration': 29.768, 'max_score': 0.209, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/cY2NXB_Tqq0/pics/cY2NXB_Tqq0209.jpg'}, {'end': 61.116, 'src': 'embed', 'start': 32.279, 'weight': 3, 'content': [{'end': 34.82, 'text': "And I'm not claiming it's the absolute best way to do this.", 'start': 32.279, 'duration': 2.541}, {'end': 37.882, 'text': "But it's something that has worked well for me up until this point.", 'start': 35.141, 'duration': 2.741}, {'end': 40.224, 'text': "So I figured I'd walk through how I do this.", 'start': 38.223, 'duration': 2.001}, {'end': 43.186, 'text': "And maybe it'll give you some ideas for how you can manage your projects.", 'start': 40.324, 'duration': 2.862}, {'end': 49.03, 'text': "But if you don't like this workflow, then like I said, there are plenty of other ways that you can accomplish this same thing.", 'start': 43.546, 'duration': 5.484}, {'end': 50.491, 'text': 'So you have plenty of options.', 'start': 49.39, 'duration': 1.101}, {'end': 55.933, 'text': "Now also I will be going over how I do this on my Mac, and I apologize if you're on a Windows machine.", 'start': 50.831, 'duration': 5.102}, {'end': 61.116, 'text': "Some of these steps will be similar on Windows, but it's likely that a lot of this will be pretty different.", 'start': 56.474, 'duration': 4.642}], 'summary': 'Sharing project management workflow on mac, adaptable for windows users too.', 'duration': 28.837, 'max_score': 32.279, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/cY2NXB_Tqq0/pics/cY2NXB_Tqq032279.jpg'}, {'end': 121.795, 'src': 'embed', 'start': 66.038, 'weight': 0, 'content': [{'end': 70.36, 'text': 'and I believe that they list the equivalent Windows commands on that website.', 'start': 66.038, 'duration': 4.322}, {'end': 73.561, 'text': "So I'll leave a link to that page in the description section below.", 'start': 70.72, 'duration': 2.841}, {'end': 75.662, 'text': "And with that said, let's go ahead and get started.", 'start': 73.941, 'duration': 1.721}, {'end': 80.223, 'text': 'Okay, so first of all, I personally do a lot of work with data science libraries and packages.', 'start': 76.042, 'duration': 4.181}, {'end': 84.044, 'text': 'So I use the Anaconda distribution and the Conda package manager.', 'start': 80.543, 'duration': 3.501}, {'end': 86.265, 'text': "Now, if you don't know what Anaconda is,", 'start': 84.344, 'duration': 1.921}, {'end': 92.567, 'text': "it's basically an open source Python distribution that makes it easy to get up and running with different libraries and packages.", 'start': 86.265, 'duration': 6.302}, {'end': 95.59, 'text': 'and it comes with its own package manager called Conda.', 'start': 92.927, 'duration': 2.663}, {'end': 101.075, 'text': 'Now, Conda is similar to pip, but certain things can be more easily installed through Conda.', 'start': 95.91, 'duration': 5.165}, {'end': 106.54, 'text': "Now, Conda isn't necessarily a replacement for pip, so you can use them both interchangeably.", 'start': 101.415, 'duration': 5.125}, {'end': 114.988, 'text': "Personally, I actually use pip about 99% of the time, and if there's something not available through pip, then I will install it through Conda.", 'start': 107.121, 'duration': 7.867}, {'end': 117.491, 'text': 'Now, Conda can also manage virtual environments.', 'start': 115.269, 'duration': 2.222}, {'end': 120.013, 'text': 'And that is what I use in my projects.', 'start': 117.871, 'duration': 2.142}, {'end': 121.795, 'text': "So we'll see that in just a bit.", 'start': 120.294, 'duration': 1.501}], 'summary': 'Anaconda distribution and conda package manager are used for data science libraries. conda can manage virtual environments.', 'duration': 55.757, 'max_score': 66.038, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/cY2NXB_Tqq0/pics/cY2NXB_Tqq066038.jpg'}, {'end': 218.311, 'src': 'heatmap', 'start': 182.31, 'weight': 0.716, 'content': [{'end': 189.994, 'text': 'so to do this, we can say conda create to create a new virtual environment, And we want this name to be.', 'start': 182.31, 'duration': 7.684}, {'end': 193.695, 'text': "since I called this my project, we'll call this my project underscore ENV.", 'start': 189.994, 'duration': 3.701}, {'end': 196.215, 'text': 'And now we can pass in our starting dependencies.', 'start': 194.095, 'duration': 2.12}, {'end': 202.997, 'text': "So like I said, we'll do flask SQL alchemy, also numpy and pandas.", 'start': 196.535, 'duration': 6.462}, {'end': 207.358, 'text': "So then it's going to list all the dependencies for all those packages.", 'start': 204.718, 'duration': 2.64}, {'end': 209.899, 'text': 'And if we want to proceed and we can just hit yes.', 'start': 207.838, 'duration': 2.061}, {'end': 218.311, 'text': "Okay, so once that's finished up, it says here that we can activate this environment using this source activate command here.", 'start': 211.164, 'duration': 7.147}], 'summary': "Create a new virtual environment 'my_project_env' with flask, sqlalchemy, numpy, and pandas dependencies.", 'duration': 36.001, 'max_score': 182.31, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/cY2NXB_Tqq0/pics/cY2NXB_Tqq0182310.jpg'}], 'start': 0.209, 'title': 'Managing multiple projects with anaconda and conda', 'summary': 'Covers managing multiple projects, virtual environments, and environment variables using anaconda and conda, focusing on their benefits such as ease of setting up libraries and packages, using conda alongside pip, and creating virtual environments with specific dependencies.', 'chapters': [{'end': 84.044, 'start': 0.209, 'title': 'Managing multiple projects and environments', 'summary': 'Explains how to manage multiple projects, virtual environments, and environment variables, focusing on using the anaconda distribution and conda package manager for data science work.', 'duration': 83.835, 'highlights': ['The chapter focuses on managing multiple projects, virtual environments, and environment variables, emphasizing the challenges of keeping packages and dependencies separate and easy to work with. The speaker discusses the difficulties of keeping packages and dependencies separate and easy to work with when working on multiple projects.', 'The speaker emphasizes that the approach presented is based on personal experience and may not be the only or best way to manage projects and environments, encouraging viewers to explore other options. The speaker acknowledges that the presented approach is based on personal experience and encourages viewers to explore alternative methods for managing projects and environments.', 'The chapter introduces the use of the Anaconda distribution and the Conda package manager for working with data science libraries and packages, addressing potential differences in workflows for Windows users. The chapter discusses the use of the Anaconda distribution and the Conda package manager for data science work, with a note on potential differences for Windows users.']}, {'end': 225.197, 'start': 84.344, 'title': 'Anaconda and conda: python environment management', 'summary': 'Explains the benefits of anaconda and conda for managing python environments, including the ease of setting up different libraries and packages, the ability to use conda alongside pip, and the creation of virtual environments with specific dependencies using conda.', 'duration': 140.853, 'highlights': ['Anaconda is an open source Python distribution that simplifies the setup of libraries and packages, and it includes its own package manager called Conda. Anaconda provides a convenient way to get up and running with various Python libraries and packages, and it features a package manager called Conda.', 'Conda allows for the easy installation of certain packages compared to pip, and it can also manage virtual environments. Conda simplifies the installation of specific packages and can manage virtual environments, offering an alternative to pip.', 'The process of creating a new virtual environment using Conda with specific dependencies, such as flask, SQL alchemy, numpy, and pandas, is detailed. The transcript outlines the step-by-step process of creating a virtual environment using Conda with specific dependencies, including flask, SQL alchemy, numpy, and pandas.']}], 'duration': 224.988, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/cY2NXB_Tqq0/pics/cY2NXB_Tqq0209.jpg', 'highlights': ['Anaconda simplifies library setup and includes Conda package manager.', 'Conda eases package installation and manages virtual environments.', 'Managing multiple projects and dependencies is a key focus of the chapter.', 'The presented approach is based on personal experience and encourages exploration of alternative methods.', 'The chapter introduces Anaconda and Conda for data science work, noting potential differences for Windows users.']}, {'end': 394.164, 'segs': [{'end': 279.94, 'src': 'embed', 'start': 247.424, 'weight': 0, 'content': [{'end': 250.707, 'text': 'But when you get to the point where you have everything that you need,', 'start': 247.424, 'duration': 3.283}, {'end': 258.853, 'text': 'I like to create an environment.yaml file that captures everything about our environment and can be used to build the same environment from scratch.', 'start': 250.707, 'duration': 8.146}, {'end': 261.815, 'text': 'So let me go ahead and do this so that you can see what it looks like.', 'start': 259.213, 'duration': 2.602}, {'end': 263.176, 'text': "So I'll clear my screen.", 'start': 262.135, 'duration': 1.041}, {'end': 268.56, 'text': 'And now to export this environment, we can say conda env export.', 'start': 263.376, 'duration': 5.184}, {'end': 273.424, 'text': 'And we want to export this to an environment.yaml file.', 'start': 268.941, 'duration': 4.483}, {'end': 279.94, 'text': 'Now, some people just use YML and some people use YAML spelled out.', 'start': 275.635, 'duration': 4.305}], 'summary': 'Creating an environment.yaml file captures everything about the environment and can be used to build the same environment from scratch.', 'duration': 32.516, 'max_score': 247.424, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/cY2NXB_Tqq0/pics/cY2NXB_Tqq0247424.jpg'}, {'end': 378.498, 'src': 'embed', 'start': 351.243, 'weight': 2, 'content': [{'end': 354.824, 'text': "okay. so now let's look at how we can manage our environment variables.", 'start': 351.243, 'duration': 3.581}, {'end': 362.489, 'text': 'Now, environment variables are used in many different projects, to you know, set database URLs or hold secret keys,', 'start': 355.145, 'duration': 7.344}, {'end': 365.411, 'text': 'or set a Python path and all kinds of different information.', 'start': 362.489, 'duration': 2.922}, {'end': 372.556, 'text': 'So the environment variables allow us to access sensitive data without putting it directly in our projects code for everyone to see.', 'start': 365.731, 'duration': 6.825}, {'end': 378.498, 'text': 'Now, some people just use global environment variables that they share amongst all different projects, and that can work.', 'start': 372.896, 'duration': 5.602}], 'summary': 'Managing environment variables allows access to sensitive data without exposing it in the code.', 'duration': 27.255, 'max_score': 351.243, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/cY2NXB_Tqq0/pics/cY2NXB_Tqq0351243.jpg'}], 'start': 226.278, 'title': 'Managing conda environments', 'summary': 'Explains how to manage conda environments, including creating an environment.yaml file to capture dependencies, replicating exact environments, and managing environment variables for secure data access.', 'chapters': [{'end': 394.164, 'start': 226.278, 'title': 'Managing conda environments', 'summary': "Explains how to manage conda environments, including creating an environment.yaml file to capture all dependencies, using it to replicate the exact environment, and managing environment variables to access sensitive data without putting it directly in the project's code.", 'duration': 167.886, 'highlights': ['Creating an environment.yaml file to capture all dependencies and replicate the exact environment Explains the process of creating an environment.yaml file to capture all dependencies and replicate the exact environment with just one command.', "Managing environment variables to access sensitive data without putting it directly in the project's code Describes the use of environment variables to access sensitive data without exposing it in the project's code, ensuring security and confidentiality.", "Using Conda env export to export the environment to an environment.yaml file Demonstrates the use of 'conda env export' to export the environment to an environment.yaml file, facilitating the recreation of the exact environment with minimal effort."]}], 'duration': 167.886, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/cY2NXB_Tqq0/pics/cY2NXB_Tqq0226278.jpg', 'highlights': ['Creating an environment.yaml file to capture all dependencies and replicate the exact environment with just one command.', 'Using Conda env export to export the environment to an environment.yaml file', "Managing environment variables to access sensitive data without putting it directly in the project's code"]}, {'end': 626.144, 'segs': [{'end': 455.591, 'src': 'heatmap', 'start': 422.259, 'weight': 3, 'content': [{'end': 429.405, 'text': "so now i'm going to change directory to the location of that virtual environment and now that we're within our virtual environment directory,", 'start': 422.259, 'duration': 7.146}, {'end': 434.149, 'text': "we're going to create two different directory trees so that we can set environment variables.", 'start': 429.405, 'duration': 4.744}, {'end': 441.536, 'text': "Now this is going to seem a little weird, but I'll put a link to the instructions in the description section below.", 'start': 434.509, 'duration': 7.027}, {'end': 448.884, 'text': "Now, first, we're going to create an activate directory, and this is going to hold scripts that will run whenever our environment is activated.", 'start': 441.777, 'duration': 7.107}, {'end': 452.508, 'text': "So to create this directory, we'll say make dir dash p.", 'start': 449.204, 'duration': 3.304}, {'end': 455.591, 'text': "That means that the directory doesn't have to currently exist.", 'start': 452.508, 'duration': 3.083}], 'summary': 'Creating directory trees for setting environment variables within virtual environment.', 'duration': 61.127, 'max_score': 422.259, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/cY2NXB_Tqq0/pics/cY2NXB_Tqq0422259.jpg'}, {'end': 516.866, 'src': 'embed', 'start': 484.283, 'weight': 1, 'content': [{'end': 489.905, 'text': "And then within that directory, we're going to call this env underscore vars dot sh.", 'start': 484.283, 'duration': 5.622}, {'end': 494.487, 'text': "And then we're going to create that exact same file in the deactivate directory also.", 'start': 490.325, 'duration': 4.162}, {'end': 505.076, 'text': 'Okay, so now we can create the environment variables that we want to set within the activate script and then unset those environment variables within the deactivate script.', 'start': 495.387, 'duration': 9.689}, {'end': 507.919, 'text': "So let's edit these files and add some variables.", 'start': 505.416, 'duration': 2.503}, {'end': 516.866, 'text': "Now you can edit those files and any text editor, but I'm going to use my sublime text editor to open up that directory that we just created.", 'start': 508.199, 'duration': 8.667}], 'summary': 'Create env_vars.sh in activate and deactivate directories for setting/unsetting environment variables.', 'duration': 32.583, 'max_score': 484.283, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/cY2NXB_Tqq0/pics/cY2NXB_Tqq0484283.jpg'}, {'end': 559.507, 'src': 'embed', 'start': 532.485, 'weight': 0, 'content': [{'end': 537.872, 'text': "Now within the activate script, let's create a fake database URI environment variable.", 'start': 532.485, 'duration': 5.387}, {'end': 544.457, 'text': "So at the top, I'm going to specify that this is a bash script by saying bin stash sh.", 'start': 538.192, 'duration': 6.265}, {'end': 556.404, 'text': "And then underneath here, I'll do an export of database underscore URI and set that equal to Okay.", 'start': 544.818, 'duration': 11.586}, {'end': 559.507, 'text': 'So this is kind of a, actually, I think this should be post SQL.', 'start': 556.424, 'duration': 3.083}], 'summary': 'Create fake database uri environment variable in a bash script.', 'duration': 27.022, 'max_score': 532.485, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/cY2NXB_Tqq0/pics/cY2NXB_Tqq0532485.jpg'}], 'start': 394.464, 'title': 'Managing virtual environment and environment variables', 'summary': 'Covers setting up virtual environment directory, creating activate and deactivate directories for environment variables, and managing environment variables using bash scripts. it demonstrates how to navigate and create necessary directory trees, set and unset environment variables, and manage a fake database uri within the virtual environment.', 'chapters': [{'end': 455.591, 'start': 394.464, 'title': 'Setting up virtual environment directory', 'summary': "Explains how to locate and navigate to the virtual environment, create necessary directory trees, and set environment variables using 'conda env list' and 'make dir' commands for efficient environment management.", 'duration': 61.127, 'highlights': ["The chapter explains how to locate the virtual environment using 'conda env list', which lists all the environments on the machine, and highlights the specific environment created, 'my project env'.", "The process involves navigating to the location of the virtual environment and creating two directory trees, 'activate' and another unspecified directory, for setting environment variables.", "Instructions are provided for creating the 'activate' directory using the 'make dir -p' command, which ensures that the directory is created if it does not exist."]}, {'end': 507.919, 'start': 456.111, 'title': 'Creating activate and deactivate directories for setting environment variables', 'summary': 'Demonstrates the process of creating activate and deactivate directories to set and unset environment variables, involving the creation of corresponding files within these directories for the purpose.', 'duration': 51.808, 'highlights': ['The process involves creating activate and deactivate directories to manage setting and unsetting of environment variables.', 'Files env_vars.sh are created within the activate and deactivate directories to add and remove environment variables.', 'The creation of activate and deactivate directories is essential for managing environment variables within scripts.']}, {'end': 626.144, 'start': 508.199, 'title': 'Creating and managing environment variables', 'summary': 'Discusses creating and managing environment variables in a virtual environment using bash scripts, including setting a fake database uri and unsetting it upon deactivation.', 'duration': 117.945, 'highlights': ["The chapter demonstrates creating a bash script to set a fake database URI environment variable, ensuring sensitive information like username and password is not hardcoded within the project's code.", 'It explains the process of unsetting the database URI environment variable upon deactivation of the virtual environment, enhancing security and preventing unauthorized access to sensitive data.', 'The example provided showcases the use of bash scripts to manage environment variables within a virtual environment, promoting best practices for maintaining secure and configurable development environments.']}], 'duration': 231.68, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/cY2NXB_Tqq0/pics/cY2NXB_Tqq0394464.jpg', 'highlights': ["The chapter demonstrates creating a bash script to set a fake database URI environment variable, ensuring sensitive information like username and password is not hardcoded within the project's code.", 'The process involves creating activate and deactivate directories to manage setting and unsetting of environment variables.', 'The example provided showcases the use of bash scripts to manage environment variables within a virtual environment, promoting best practices for maintaining secure and configurable development environments.', "Instructions are provided for creating the 'activate' directory using the 'make dir -p' command, which ensures that the directory is created if it does not exist.", "The process involves navigating to the location of the virtual environment and creating two directory trees, 'activate' and another unspecified directory, for setting environment variables.", "The chapter explains how to locate the virtual environment using 'conda env list', which lists all the environments on the machine, and highlights the specific environment created, 'my project env'."]}, {'end': 814.959, 'segs': [{'end': 698.341, 'src': 'embed', 'start': 654.053, 'weight': 0, 'content': [{'end': 660.515, 'text': 'So now, if I deactivate this virtual environment, say source deactivate Now.', 'start': 654.053, 'duration': 6.462}, {'end': 663.137, 'text': 'if I try to echo out this database URI,', 'start': 660.515, 'duration': 2.622}, {'end': 668.801, 'text': "then you can see that now that doesn't exist because we unset that whenever we deactivated our virtual environment.", 'start': 663.137, 'duration': 5.664}, {'end': 675.445, 'text': 'OK, so so far we have our Python version, our dependencies and the environment variables all separated out.', 'start': 669.141, 'duration': 6.304}, {'end': 683.09, 'text': "So, for example, I have another test project here that I've created in my projects directory called Query MS underscore web.", 'start': 675.766, 'duration': 7.324}, {'end': 686.533, 'text': 'So let me navigate to that project really quick.', 'start': 683.391, 'duration': 3.142}, {'end': 689.515, 'text': 'And that is Query MS underscore web.', 'start': 687.033, 'duration': 2.482}, {'end': 693.698, 'text': "And now let's look at the files I have available in here.", 'start': 690.696, 'duration': 3.002}, {'end': 696.219, 'text': "Oh, and actually I'm in the wrong location.", 'start': 693.718, 'duration': 2.501}, {'end': 698.341, 'text': 'This is the virtual environment directory.', 'start': 696.259, 'duration': 2.082}], 'summary': 'Demonstrates setting up and navigating virtual environments for python projects.', 'duration': 44.288, 'max_score': 654.053, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/cY2NXB_Tqq0/pics/cY2NXB_Tqq0654053.jpg'}, {'end': 751.783, 'src': 'embed', 'start': 723.5, 'weight': 4, 'content': [{'end': 729.986, 'text': "And in our dependencies, one thing to note here is that we're using Python 2.7 instead of Python 3.", 'start': 723.5, 'duration': 6.486}, {'end': 733.189, 'text': 'So you can have different versions of Python between different environments.', 'start': 729.986, 'duration': 3.203}, {'end': 741.557, 'text': "And we can see that the environment is using the same dependencies that we listed before, except we're also including a scipy down here at the bottom.", 'start': 733.609, 'duration': 7.948}, {'end': 745.379, 'text': "Now, I've already created this environment from this YAML file.", 'start': 741.957, 'duration': 3.422}, {'end': 751.783, 'text': "So let's navigate to the location of this virtual environment and see if any variables are being set.", 'start': 745.679, 'duration': 6.104}], 'summary': 'Using python 2.7 instead of python 3, different environments can have different python versions, same dependencies as listed before with addition of scipy.', 'duration': 28.283, 'max_score': 723.5, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/cY2NXB_Tqq0/pics/cY2NXB_Tqq0723500.jpg'}, {'end': 827.683, 'src': 'embed', 'start': 793.885, 'weight': 2, 'content': [{'end': 796.726, 'text': "So that's why it's beneficial to keep these environments separate.", 'start': 793.885, 'duration': 2.841}, {'end': 803.331, 'text': 'So when we activate our other project, it will set that environment variable to its database.', 'start': 797.066, 'duration': 6.265}, {'end': 810.736, 'text': 'And when we deactivate and activate our Query MS project, it will correctly set the database to this database.', 'start': 803.691, 'duration': 7.045}, {'end': 814.959, 'text': "So let's activate this Query MS environment really quick.", 'start': 811.096, 'duration': 3.863}, {'end': 827.683, 'text': 'So if I close out of my text editor, and we activate this with source activate quarryms underscore web, and then we echo out that database URI.', 'start': 815.119, 'duration': 12.564}], 'summary': 'Separating environments ensures correct database settings for different projects.', 'duration': 33.798, 'max_score': 793.885, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/cY2NXB_Tqq0/pics/cY2NXB_Tqq0793885.jpg'}], 'start': 626.144, 'title': 'Managing python environments', 'summary': 'Covers managing python virtual environments in python 2.7 and demonstrates activating, deactivating, setting environment variables, and navigating project directories. it also emphasizes the benefits of keeping environments separate.', 'chapters': [{'end': 723.02, 'start': 626.144, 'title': 'Managing virtual environments in python', 'summary': 'Demonstrates activating and deactivating a virtual environment in python, setting and unsetting environment variables, and navigating between different project directories.', 'duration': 96.876, 'highlights': ['Setting and unsetting environment variables when activating and deactivating virtual environments, demonstrated using the example of database URI, provides a clear understanding of managing environment variables in Python.', "Navigating between different project directories and identifying the correct location for files, as shown in the example of navigating to the 'Query MS_web' project directory, helps in efficiently managing multiple projects.", 'Demonstrating the separation of Python versions, dependencies, and environment variables aids in maintaining clear distinctions between different projects and their requirements.']}, {'end': 814.959, 'start': 723.5, 'title': 'Managing python 2.7 virtual environments', 'summary': 'Discusses creating and managing python 2.7 virtual environments, including setting up dependencies and environment variables, with an emphasis on the benefits of keeping environments separate.', 'duration': 91.459, 'highlights': ['The chapter emphasizes using Python 2.7 instead of Python 3 for different environments, with a specific focus on managing dependencies and including scipy (scientific computing library) in the environment.', 'The process of navigating to the virtual environment location, checking for variables being set, and utilizing activate and deactivate scripts is demonstrated, highlighting the importance of keeping environments separate for setting correct database connections.', 'The chapter showcases the significance of keeping environments separate by illustrating how activating different projects sets the environment variable to their respective databases, thus ensuring correct database connections.']}], 'duration': 188.815, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/cY2NXB_Tqq0/pics/cY2NXB_Tqq0626144.jpg', 'highlights': ['Setting and unsetting environment variables when activating and deactivating virtual environments, demonstrated using the example of database URI, provides a clear understanding of managing environment variables in Python.', 'The process of navigating to the virtual environment location, checking for variables being set, and utilizing activate and deactivate scripts is demonstrated, highlighting the importance of keeping environments separate for setting correct database connections.', 'The chapter showcases the significance of keeping environments separate by illustrating how activating different projects sets the environment variable to their respective databases, thus ensuring correct database connections.', "Navigating between different project directories and identifying the correct location for files, as shown in the example of navigating to the 'Query MS_web' project directory, helps in efficiently managing multiple projects.", 'Demonstrating the separation of Python versions, dependencies, and environment variables aids in maintaining clear distinctions between different projects and their requirements.', 'The chapter emphasizes using Python 2.7 instead of Python 3 for different environments, with a specific focus on managing dependencies and including scipy (scientific computing library) in the environment.']}, {'end': 1042.387, 'segs': [{'end': 858.792, 'src': 'embed', 'start': 815.119, 'weight': 0, 'content': [{'end': 827.683, 'text': 'So if I close out of my text editor, and we activate this with source activate quarryms underscore web, and then we echo out that database URI.', 'start': 815.119, 'duration': 12.564}, {'end': 833.604, 'text': 'Then we can see that our database URI now has that correct database for that project.', 'start': 828.503, 'duration': 5.101}, {'end': 840.346, 'text': "And also, if we check our version of Python, so I'll run a Python here, you can see that this is using Python 2.7 for this project.", 'start': 833.884, 'duration': 6.462}, {'end': 848.008, 'text': "So we're able to switch between versions of Python as well, which is extremely beneficial for different projects.", 'start': 842.086, 'duration': 5.922}, {'end': 849.889, 'text': "Okay, so we're almost finished up.", 'start': 848.408, 'duration': 1.481}, {'end': 856.191, 'text': "Now for most people, you could stop here and you've got a great way of separating out your projects and environments from each other.", 'start': 850.209, 'duration': 5.982}, {'end': 858.792, 'text': "But there's one more thing that I usually like to set up.", 'start': 856.531, 'duration': 2.261}], 'summary': 'Activating and configuring project environment with python 2.7 and database uri for project separation.', 'duration': 43.673, 'max_score': 815.119, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/cY2NXB_Tqq0/pics/cY2NXB_Tqq0815119.jpg'}, {'end': 943.926, 'src': 'embed', 'start': 878.42, 'weight': 3, 'content': [{'end': 886.043, 'text': 'Now, my personal preference is to have something in place that checks, when you navigate to a project, whether that project has an environment.yaml.', 'start': 878.42, 'duration': 7.623}, {'end': 889.205, 'text': 'file, and to activate that environment if it exists.', 'start': 886.043, 'duration': 3.162}, {'end': 892.626, 'text': 'Now there are programs out there that will do something like this for you.', 'start': 889.585, 'duration': 3.041}, {'end': 898.509, 'text': "So maybe you've heard of things like autoenv or direnv and tools like that.", 'start': 892.966, 'duration': 5.543}, {'end': 901.97, 'text': 'But for conda, I just prefer to use my own function to do this.', 'start': 898.909, 'duration': 3.061}, {'end': 912.134, 'text': "Now I modified this function from some code that I found online and I will put a link to the original function in the description section below so that they're sure to get credit.", 'start': 902.33, 'duration': 9.804}, {'end': 919.757, 'text': 'But basically to do this, we need to write a bash function that checks for the virtual environment and automatically activates it if it finds one.', 'start': 912.394, 'duration': 7.363}, {'end': 923.659, 'text': 'And then we need to set an environment variable called prompt command.', 'start': 920.198, 'duration': 3.461}, {'end': 927.5, 'text': 'that will run this custom function before each bash prompt.', 'start': 924.099, 'duration': 3.401}, {'end': 935.783, 'text': "So let's open up my bash underscore profile file and we can see how we can create this function and environment variable.", 'start': 927.86, 'duration': 7.923}, {'end': 943.926, 'text': "So I'm just going to open this up in nano and this is in my home directory and it is the dot underscore bash profile.", 'start': 936.063, 'duration': 7.863}], 'summary': 'Activating virtual environment automatically with custom bash function for conda.', 'duration': 65.506, 'max_score': 878.42, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/cY2NXB_Tqq0/pics/cY2NXB_Tqq0878420.jpg'}], 'start': 815.119, 'title': 'Managing python environments and databases', 'summary': 'Demonstrates activating python environments, updating database uris, and switching python versions for flexibility. it also covers the importance of automatic project environment activation, using a custom function to check and activate virtual environments, and setting a prompt command environment variable.', 'chapters': [{'end': 858.792, 'start': 815.119, 'title': 'Managing python environments and databases', 'summary': 'Demonstrates activating a python environment and updating a database uri, also showcasing the ability to switch between python versions, providing flexibility for different projects.', 'duration': 43.673, 'highlights': ['Switching between Python versions provides flexibility for different projects.', 'Activating a Python environment and updating the database URI.', 'Demonstrating the use of Python 2.7 for this project.']}, {'end': 1042.387, 'start': 859.192, 'title': 'Automatic project environment activation', 'summary': 'Discusses the importance of automatically activating project environments, using a custom function to check for a virtual environment and activate it if found, and setting a prompt command environment variable to run the custom function before each bash prompt.', 'duration': 183.195, 'highlights': ['Creating a custom function to automatically activate project environments by checking for the virtual environment and activating it if found.', 'Setting a prompt command environment variable to run the custom function before each bash prompt, facilitating automatic activation of project environments.', 'Discussing the preference for using a custom function over existing programs like autoenv or direnv for managing project environments.']}], 'duration': 227.268, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/cY2NXB_Tqq0/pics/cY2NXB_Tqq0815119.jpg', 'highlights': ['Switching between Python versions provides flexibility for different projects.', 'Activating a Python environment and updating the database URI.', 'Demonstrating the use of Python 2.7 for this project.', 'Creating a custom function to automatically activate project environments by checking for the virtual environment and activating it if found.', 'Setting a prompt command environment variable to run the custom function before each bash prompt, facilitating automatic activation of project environments.', 'Discussing the preference for using a custom function over existing programs like autoenv or direnv for managing project environments.']}, {'end': 1235.804, 'segs': [{'end': 1067.829, 'src': 'embed', 'start': 1042.387, 'weight': 0, 'content': [{'end': 1051.255, 'text': "so now, if we navigate to our project, so within projects, i'm navigating to this my project directory.", 'start': 1042.387, 'duration': 8.868}, {'end': 1055.599, 'text': 'now. i expected that to activate automatically.', 'start': 1051.255, 'duration': 4.344}, {'end': 1058.862, 'text': "Okay, it's because I misspelled environment here.", 'start': 1056.099, 'duration': 2.763}, {'end': 1061.504, 'text': "So I'm going to rename this file.", 'start': 1059.202, 'duration': 2.302}, {'end': 1065.247, 'text': "So I'm going to move that and spell this correctly.", 'start': 1061.524, 'duration': 3.723}, {'end': 1067.829, 'text': 'So that is environment.yaml.', 'start': 1065.327, 'duration': 2.502}], 'summary': 'Renamed the file to environment.yaml to activate project automatically.', 'duration': 25.442, 'max_score': 1042.387, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/cY2NXB_Tqq0/pics/cY2NXB_Tqq01042387.jpg'}, {'end': 1136.393, 'src': 'embed', 'start': 1093.602, 'weight': 1, 'content': [{'end': 1102.454, 'text': 'Okay, so now we can see that we are connected to our test database here, or we have that database environment variable set.', 'start': 1093.602, 'duration': 8.852}, {'end': 1112.926, 'text': 'So now, if I navigate to my other project, which is called Query MS Web, As soon as I navigate into there,', 'start': 1102.814, 'duration': 10.112}, {'end': 1116.186, 'text': 'then it sets that Query MS web environment variable.', 'start': 1112.926, 'duration': 3.26}, {'end': 1124.629, 'text': "So now if we check that same database URI environment variable again, we can see that now it's set to that different database.", 'start': 1116.506, 'duration': 8.123}, {'end': 1130.17, 'text': 'So with that prompt command, environment variable running that conda autoenv function,', 'start': 1124.949, 'duration': 5.221}, {'end': 1133.731, 'text': 'then we can see that the environment automatically gets activated.', 'start': 1130.17, 'duration': 3.561}, {'end': 1136.393, 'text': "So it changes the Python that we're using.", 'start': 1134.051, 'duration': 2.342}], 'summary': 'Switching projects changes database uri, activates environment, and changes python version.', 'duration': 42.791, 'max_score': 1093.602, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/cY2NXB_Tqq0/pics/cY2NXB_Tqq01093602.jpg'}, {'end': 1196.924, 'src': 'embed', 'start': 1168.681, 'weight': 4, 'content': [{'end': 1173.245, 'text': 'I hope that this gave you some good ideas for how you can juggle multiple projects.', 'start': 1168.681, 'duration': 4.564}, {'end': 1181.452, 'text': "even if you're working on projects with different Python versions or different Python packages and a lot of different environment variables.", 'start': 1173.245, 'duration': 8.207}, {'end': 1185.315, 'text': 'it should be easy to keep everything separate using a strategy like this.', 'start': 1181.452, 'duration': 3.863}, {'end': 1191.92, 'text': "Now, like I said, this is how I personally do this, but even if you aren't using Anaconda or the Conda environments,", 'start': 1185.795, 'duration': 6.125}, {'end': 1196.924, 'text': 'then you can still do something like this using virtualenv and tools like autoenv.', 'start': 1191.92, 'duration': 5.004}], 'summary': 'Strategies for managing multiple projects with different python versions and packages discussed.', 'duration': 28.243, 'max_score': 1168.681, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/cY2NXB_Tqq0/pics/cY2NXB_Tqq01168681.jpg'}], 'start': 1042.387, 'title': 'Activating and managing virtual environments', 'summary': 'Outlines activating a virtual environment, setting environment variables, and managing multiple projects with anaconda. it demonstrates successful activation and settings in my project and query ms web projects, as well as managing multiple projects, handling different python versions and packages, and simplifying organization.', 'chapters': [{'end': 1116.186, 'start': 1042.387, 'title': 'Activating virtual environment and setting environment variables', 'summary': 'Outlines the process of activating a virtual environment and setting environment variables, demonstrating the successful activation of the virtual environment and the setting of environment variables in the my project and query ms web projects.', 'duration': 73.799, 'highlights': ["The virtual environment 'My Project' is successfully activated after correcting the file name from environment to environment.yaml, indicating the successful activation of the virtual environment in the project.", 'The environment variable for the test database is successfully set, demonstrating the successful setting of environment variables in the My Project.', "The 'Query MS Web' environment variable is automatically set upon navigating into the project, showcasing the automatic setting of environment variables in the Query MS Web project."]}, {'end': 1235.804, 'start': 1116.506, 'title': 'Managing multiple projects with anaconda', 'summary': 'Demonstrates how to manage multiple projects with anaconda by automatically activating the correct environment, handling different python versions and packages, and simplifying the process of keeping everything separate and organized.', 'duration': 119.298, 'highlights': ['By using the conda autoenv function, the environment automatically gets activated, changing the Python being used and setting the environment variables, simplifying the process of handling different Python versions and packages.', 'The strategy helps in juggling multiple projects, even with different Python versions or packages, by automatically handling environment variables and keeping everything separate, aiding in efficient project management.', 'Even without using Anaconda or Conda environments, a similar workflow can be achieved using virtualenv and tools like autoenv, offering flexibility to users in managing multiple projects with different environments.', 'Support for the tutorial can be shown by liking and sharing the video, contributing through Patreon, and subscribing for future videos, providing various ways to support and engage with the content.']}], 'duration': 193.417, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/cY2NXB_Tqq0/pics/cY2NXB_Tqq01042387.jpg', 'highlights': ["The virtual environment 'My Project' is successfully activated after correcting the file name from environment to environment.yaml, indicating the successful activation of the virtual environment in the project.", 'By using the conda autoenv function, the environment automatically gets activated, changing the Python being used and setting the environment variables, simplifying the process of handling different Python versions and packages.', 'The environment variable for the test database is successfully set, demonstrating the successful setting of environment variables in the My Project.', "The 'Query MS Web' environment variable is automatically set upon navigating into the project, showcasing the automatic setting of environment variables in the Query MS Web project.", 'The strategy helps in juggling multiple projects, even with different Python versions or packages, by automatically handling environment variables and keeping everything separate, aiding in efficient project management.']}], 'highlights': ['Creating an environment.yaml file to capture all dependencies and replicate the exact environment with just one command.', 'Using Conda env export to export the environment to an environment.yaml file', "The chapter demonstrates creating a bash script to set a fake database URI environment variable, ensuring sensitive information like username and password is not hardcoded within the project's code.", 'The process involves creating activate and deactivate directories to manage setting and unsetting of environment variables.', 'The example provided showcases the use of bash scripts to manage environment variables within a virtual environment, promoting best practices for maintaining secure and configurable development environments.', 'Setting and unsetting environment variables when activating and deactivating virtual environments, demonstrated using the example of database URI, provides a clear understanding of managing environment variables in Python.', 'The process of navigating to the virtual environment location, checking for variables being set, and utilizing activate and deactivate scripts is demonstrated, highlighting the importance of keeping environments separate for setting correct database connections.', 'The chapter showcases the significance of keeping environments separate by illustrating how activating different projects sets the environment variable to their respective databases, thus ensuring correct database connections.', "Navigating between different project directories and identifying the correct location for files, as shown in the example of navigating to the 'Query MS_web' project directory, helps in efficiently managing multiple projects.", 'Demonstrating the separation of Python versions, dependencies, and environment variables aids in maintaining clear distinctions between different projects and their requirements.', 'Switching between Python versions provides flexibility for different projects.', 'Activating a Python environment and updating the database URI.', 'Creating a custom function to automatically activate project environments by checking for the virtual environment and activating it if found.', 'Setting a prompt command environment variable to run the custom function before each bash prompt, facilitating automatic activation of project environments.', "The virtual environment 'My Project' is successfully activated after correcting the file name from environment to environment.yaml, indicating the successful activation of the virtual environment in the project.", 'By using the conda autoenv function, the environment automatically gets activated, changing the Python being used and setting the environment variables, simplifying the process of handling different Python versions and packages.', 'The environment variable for the test database is successfully set, demonstrating the successful setting of environment variables in the My Project.', "The 'Query MS Web' environment variable is automatically set upon navigating into the project, showcasing the automatic setting of environment variables in the Query MS Web project.", 'The strategy helps in juggling multiple projects, even with different Python versions or packages, by automatically handling environment variables and keeping everything separate, aiding in efficient project management.']}