title
Python Tutorial: Pipenv - Easily Manage Packages and Virtual Environments

description
In this Python Programming Tutorial, we will be learning how to use Pipenv. Pipenv is a new package manager that combines pip and virtualenv into one easy-to-use tool. We will learn how to install pipenv, how to install new packages, how to manage our newly created environment for our project, and also look at some more advanced use cases. Let's get started... The requirements.txt used in this tutorial can be found here: https://github.com/CoreyMSchafer/code_snippets/tree/master/Python/Pipenv PATH Videos: Mac/Linux: https://youtu.be/PUIE7CPANfo Windows: https://youtu.be/OdIHeg4jj2c ✅ 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 #Pipenv

detail
{'title': 'Python Tutorial: Pipenv - Easily Manage Packages and Virtual Environments', 'heatmap': [{'end': 256.589, 'start': 230.997, 'weight': 1}, {'end': 703.287, 'start': 681.63, 'weight': 0.922}, {'end': 1150.792, 'start': 1123.733, 'weight': 0.715}], 'summary': 'This tutorial introduces pipenv, a tool for package and virtual environment management, favored as an alternative to pip and virtualenv. it covers installation, package management, python environment management, security, managing environment variables using .env files, and transitioning from pip to pipenv, emphasizing the benefits of isolating project packages and ensuring deterministic builds through pipfile.lock.', 'chapters': [{'end': 149.538, 'segs': [{'end': 58.242, 'src': 'embed', 'start': 35.511, 'weight': 4, 'content': [{'end': 42.897, 'text': "pip is a way for us to install additional packages that allows us to add a ton of functionality that doesn't exist in the Python standard library.", 'start': 35.511, 'duration': 7.386}, {'end': 49.879, 'text': 'So for example, if you want to do some image manipulation, then Python might not have the best tools available right out of the box.', 'start': 43.437, 'duration': 6.442}, {'end': 54.901, 'text': 'But you can use pip to install the pillow library and use that to work with images.', 'start': 50.259, 'duration': 4.642}, {'end': 58.242, 'text': 'So I guess that a lot of people have probably seen pip before.', 'start': 55.261, 'duration': 2.981}], 'summary': "Pip enables installing additional packages to enhance python's functionality, such as the pillow library for image manipulation.", 'duration': 22.731, 'max_score': 35.511, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/zDYL22QNiWk/pics/zDYL22QNiWk35511.jpg'}, {'end': 136.493, 'src': 'embed', 'start': 92, 'weight': 0, 'content': [{'end': 100.409, 'text': 'Some people put off learning virtual environments and just try to run every project using their global installation of Python and all the packages installed in one place.', 'start': 92, 'duration': 8.409}, {'end': 106.176, 'text': 'But if you do it that way, then as soon as you update to the next version of Python or update your packages,', 'start': 100.77, 'duration': 5.406}, {'end': 110.099, 'text': 'then it could break some of your older applications that were running just fine.', 'start': 106.556, 'duration': 3.543}, {'end': 113.402, 'text': "So it's best to split those up using virtual environments.", 'start': 110.52, 'duration': 2.882}, {'end': 121.35, 'text': 'So before pipenv, we used pip to handle package management and used virtualenv to handle virtual environments.', 'start': 113.763, 'duration': 7.587}, {'end': 125.351, 'text': 'but now with pipenv, these can all be handled by one tool.', 'start': 121.71, 'duration': 3.641}, {'end': 127.291, 'text': 'that simplifies the process.', 'start': 125.351, 'duration': 1.94}, {'end': 129.991, 'text': "so let's get started and see what this looks like.", 'start': 127.291, 'duration': 2.7}, {'end': 136.493, 'text': 'so first we want to install pipenv and we can simply install pipenv by using pip.', 'start': 129.991, 'duration': 6.502}], 'summary': 'Using virtual environments prevents breakage when updating python or packages. pipenv simplifies package and virtual environment management.', 'duration': 44.493, 'max_score': 92, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/zDYL22QNiWk/pics/zDYL22QNiWk92000.jpg'}], 'start': 0.249, 'title': 'Learning pipenv for package and virtual environment management', 'summary': 'Introduces pipenv, a tool combining package management with virtual environments, favored by many teams and companies as an alternative to pip and virtualenv. it explains the benefits of using virtual environments for project-specific python and package versions.', 'chapters': [{'end': 149.538, 'start': 0.249, 'title': 'Learning pipenv for package and virtual environment management', 'summary': 'Introduces pipenv as a tool combining package management with virtual environments, favored by many teams and companies as an alternative to pip and virtualenv, and explains the benefits of using virtual environments for project-specific python and package versions.', 'duration': 149.289, 'highlights': ['Pipenv simplifies package management and virtual environment handling, favored by many teams and companies as an alternative to pip and virtualenv.', 'Virtual environments provide project-specific environments for Python and package versions, preventing conflicts and issues when updating Python or packages.', "Pip is used to install additional packages, expanding Python's functionality, while virtualenv creates specific environments for each project.", 'Global installation of Python and packages for all projects can lead to issues when updating Python or packages, emphasizing the need for virtual environments.', "Pipenv installation can be done easily using 'pip install pipenv', simplifying the process of combining package management and virtual environments."]}], 'duration': 149.289, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/zDYL22QNiWk/pics/zDYL22QNiWk249.jpg', 'highlights': ['Pipenv simplifies package management and virtual environment handling, favored by many teams and companies as an alternative to pip and virtualenv.', 'Virtual environments provide project-specific environments for Python and package versions, preventing conflicts and issues when updating Python or packages.', "Pipenv installation can be done easily using 'pip install pipenv', simplifying the process of combining package management and virtual environments.", 'Global installation of Python and packages for all projects can lead to issues when updating Python or packages, emphasizing the need for virtual environments.', "Pip is used to install additional packages, expanding Python's functionality, while virtualenv creates specific environments for each project."]}, {'end': 487.648, 'segs': [{'end': 256.589, 'src': 'heatmap', 'start': 205.804, 'weight': 1, 'content': [{'end': 213.049, 'text': 'And then we would need to manually activate that environment and then start installing the packages that we want to use in this project.', 'start': 205.804, 'duration': 7.245}, {'end': 216.251, 'text': 'But with Pippi and Vee, this is all built in together now.', 'start': 213.449, 'duration': 2.802}, {'end': 223.794, 'text': "So instead of creating a new virtual environment manually, We're simply going to install the packages that we want with pipenv.", 'start': 216.671, 'duration': 7.123}, {'end': 227.576, 'text': "So let's say that we want to use the request package for this project.", 'start': 224.195, 'duration': 3.381}, {'end': 230.517, 'text': "If you haven't used the request library, then don't worry about it.", 'start': 227.956, 'duration': 2.561}, {'end': 234.038, 'text': "We're really just choosing a random package to install for this project.", 'start': 230.997, 'duration': 3.041}, {'end': 239.7, 'text': "So to install this, let's say pipenv install requests.", 'start': 234.398, 'duration': 5.302}, {'end': 245.845, 'text': 'OK, so we can see that it did a few things there.', 'start': 243.624, 'duration': 2.221}, {'end': 249.086, 'text': "So once that is finished, let's take a look at what this did.", 'start': 246.245, 'duration': 2.841}, {'end': 256.589, 'text': 'So right off the bat, if we scroll up here to the top, where we ran that command right after we installed requests,', 'start': 249.866, 'duration': 6.723}], 'summary': 'Pipenv simplifies package installation, e.g. pipenv install requests.', 'duration': 43.282, 'max_score': 205.804, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/zDYL22QNiWk/pics/zDYL22QNiWk205804.jpg'}, {'end': 315.007, 'src': 'embed', 'start': 291.184, 'weight': 0, 'content': [{'end': 297.767, 'text': "And that virtual environment that it created is actually just a regular virtual environment like you'd be used to using in the past.", 'start': 291.184, 'duration': 6.583}, {'end': 301.852, 'text': "So you can navigate to that location and activate it manually if you'd like.", 'start': 298.287, 'duration': 3.565}, {'end': 307.778, 'text': 'But pipenv gives us simpler commands to interact with that environment than to just do it manually.', 'start': 302.352, 'duration': 5.426}, {'end': 311.202, 'text': 'Okay, and next it says that it created a pip file.', 'start': 308.119, 'duration': 3.083}, {'end': 315.007, 'text': 'The pip file is going to be a file that describes our environment.', 'start': 311.723, 'duration': 3.284}], 'summary': 'Pipenv creates a regular virtual environment with simpler commands, and a pip file to describe the environment.', 'duration': 23.823, 'max_score': 291.184, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/zDYL22QNiWk/pics/zDYL22QNiWk291184.jpg'}, {'end': 418.765, 'src': 'embed', 'start': 377.307, 'weight': 4, 'content': [{'end': 385.511, 'text': "So pipfile.loc is another file that gets created and it's similar to our pip file but with some key differences that we'll see throughout the video.", 'start': 377.307, 'duration': 8.204}, {'end': 389.934, 'text': "Basically, pipfile.loc is a file that we're not supposed to touch.", 'start': 385.571, 'duration': 4.363}, {'end': 394.216, 'text': "It's just a file that gets generated and produces deterministic builds.", 'start': 390.294, 'duration': 3.922}, {'end': 396.697, 'text': "And again, we'll see more about that in just a bit.", 'start': 394.636, 'duration': 2.061}, {'end': 406.361, 'text': 'Okay, so lastly, here at the bottom, we can see that it tells us that we can activate our new environment simply by saying pipenv shell.', 'start': 397.058, 'duration': 9.303}, {'end': 412.603, 'text': 'And if we just want to run a command inside that virtual environment, then we can do pipenv run.', 'start': 407.101, 'duration': 5.502}, {'end': 418.765, 'text': "But before we activate the virtual environment, let's first look at the pip file and the pip file.lock.", 'start': 413.343, 'duration': 5.422}], 'summary': "Pipfile.loc is generated for deterministic builds, and we can activate a new environment with 'pipenv shell' and run commands with 'pipenv run'.", 'duration': 41.458, 'max_score': 377.307, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/zDYL22QNiWk/pics/zDYL22QNiWk377307.jpg'}], 'start': 149.538, 'title': 'Pipenv for package management', 'summary': 'Covers installing packages and creating a virtual environment using pipenv, which streamlines the process by automatically creating a virtual environment, installing packages, and creating a pip file in one step. it also explains the pipenv installation process, including creating a pipfile, installing packages, generating the pipfile.lock, and activating the new environment.', 'chapters': [{'end': 290.883, 'start': 149.538, 'title': 'Installing packages with pipenv', 'summary': 'Covers the process of installing packages and creating a virtual environment using pipenv, which automatically creates a virtual environment, installs packages, and creates a pip file, all in one step, providing an efficient and convenient way to manage project dependencies.', 'duration': 141.345, 'highlights': ['Pipenv automatically creates a virtual environment, installs packages, and creates a PIP file, streamlining the process of managing project dependencies.', "By using 'pipenv install requests', a virtual environment is created, and the request package is installed, demonstrating the simplicity and efficiency of Pipenv.", 'The virtual environment is created and located within a virtualenvs directory, showcasing the organization and accessibility of the environment setup.']}, {'end': 487.648, 'start': 291.184, 'title': 'Pipenv installation process', 'summary': 'Explains the process of creating a virtual environment using pipenv, including the creation of a pipfile, installation of packages, and the generation of the pipfile.lock, and concludes with instructions on activating the new environment.', 'duration': 196.464, 'highlights': ["Pipenv creates a pipfile to describe the environment and can install packages like 'requests'.", "Pipenv installs the 'requests' package and adds it to the pipfile's packages.", 'Pipenv generates the pipfile.lock for deterministic builds.', "Instructions for activating the new virtual environment using 'pipenv shell' and running commands within it with 'pipenv run'."]}], 'duration': 338.11, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/zDYL22QNiWk/pics/zDYL22QNiWk149538.jpg', 'highlights': ['Pipenv automatically creates a virtual environment, installs packages, and creates a PIP file, streamlining the process of managing project dependencies.', "By using 'pipenv install requests', a virtual environment is created, and the request package is installed, demonstrating the simplicity and efficiency of Pipenv.", "Pipenv creates a pipfile to describe the environment and can install packages like 'requests'.", 'The virtual environment is created and located within a virtualenvs directory, showcasing the organization and accessibility of the environment setup.', 'Pipenv generates the pipfile.lock for deterministic builds.', "Instructions for activating the new virtual environment using 'pipenv shell' and running commands within it with 'pipenv run'."]}, {'end': 787.611, 'segs': [{'end': 555.834, 'src': 'embed', 'start': 527.188, 'weight': 2, 'content': [{'end': 533.849, 'text': "Okay, and lastly, we can also see down here at the bottom that we are specifying which version of Python that we're using.", 'start': 527.188, 'duration': 6.661}, {'end': 538.29, 'text': "So I'm using Python 3.7, but we could change that if we'd like.", 'start': 534.309, 'duration': 3.981}, {'end': 541.911, 'text': 'Okay, so that is a quick overview of the pip file.', 'start': 539.09, 'duration': 2.821}, {'end': 546.872, 'text': "It's a pretty simple file that just shows how we can create a new environment from scratch.", 'start': 542.571, 'duration': 4.301}, {'end': 549.052, 'text': 'And this file is also meant to be editable.', 'start': 547.212, 'duration': 1.84}, {'end': 555.834, 'text': 'we could add packages in here and rerun the install command, and it would install the packages that we added.', 'start': 549.632, 'duration': 6.202}], 'summary': 'Overview of pip file specifying python version, editable for adding packages and creating new environment.', 'duration': 28.646, 'max_score': 527.188, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/zDYL22QNiWk/pics/zDYL22QNiWk527188.jpg'}, {'end': 659.2, 'src': 'embed', 'start': 617.762, 'weight': 0, 'content': [{'end': 620.384, 'text': 'So this will give you a deterministic build.', 'start': 617.762, 'duration': 2.622}, {'end': 626.687, 'text': 'And what I mean by that is that this lock file will absolutely give you the exact same environment every time.', 'start': 620.764, 'duration': 5.923}, {'end': 631.13, 'text': 'And you only get a different build when you explicitly update the lock file.', 'start': 627.108, 'duration': 4.022}, {'end': 633.371, 'text': "And we'll see how to do this in just a bit.", 'start': 631.57, 'duration': 1.801}, {'end': 639.394, 'text': 'So this gets us around the problem that we had before where I said that updating packages can break your project.', 'start': 633.771, 'duration': 5.623}, {'end': 644.835, 'text': 'So the pip file could see a new version of your package and update them accordingly.', 'start': 639.774, 'duration': 5.061}, {'end': 651.677, 'text': "And then, once you're sure that all of your code is still working in development, after you've updated those packages,", 'start': 645.476, 'duration': 6.201}, {'end': 659.2, 'text': 'then you can simply update your lock file, which will give you the exact packages that are installed at the time that you know work well.', 'start': 651.677, 'duration': 7.523}], 'summary': 'Using a lock file ensures a deterministic build, providing the exact same environment and preventing unintended package updates, maintaining stability.', 'duration': 41.438, 'max_score': 617.762, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/zDYL22QNiWk/pics/zDYL22QNiWk617762.jpg'}, {'end': 708.488, 'src': 'heatmap', 'start': 679.689, 'weight': 3, 'content': [{'end': 681.03, 'text': "I'm going to clear the screen.", 'start': 679.689, 'duration': 1.341}, {'end': 685.653, 'text': 'So to activate our environment, we can simply say pipenv shell.', 'start': 681.63, 'duration': 4.023}, {'end': 689.076, 'text': 'And we can see here it says launching subshell and virtual environment.', 'start': 686.254, 'duration': 2.822}, {'end': 689.977, 'text': 'Yours may not say that.', 'start': 689.096, 'duration': 0.881}, {'end': 691.197, 'text': "If it doesn't, that's fine.", 'start': 690.037, 'duration': 1.16}, {'end': 697.322, 'text': 'But if I clear my screen here now, then that should have activated our environment for our project.', 'start': 691.918, 'duration': 5.404}, {'end': 703.287, 'text': 'Now, usually when you have an environment activated, it will add something to the beginning of your prompt in the command line.', 'start': 697.662, 'duration': 5.625}, {'end': 704.987, 'text': "And it's doing that here.", 'start': 703.727, 'duration': 1.26}, {'end': 708.488, 'text': 'So we can see that in parentheses here, it says my project.', 'start': 705.147, 'duration': 3.341}], 'summary': "Activating the environment using 'pipenv shell' launches subshell and virtual environment, adding project name to prompt.", 'duration': 28.799, 'max_score': 679.689, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/zDYL22QNiWk/pics/zDYL22QNiWk679689.jpg'}], 'start': 488.108, 'title': 'Python environment management with pipenv', 'summary': "Explains pipenv's features such as automatic package updates, risk mitigation through pipfile.lock, and creating isolated environments, emphasizing the importance of pipfile.lock in ensuring a deterministic build and the benefits of isolating project packages.", 'chapters': [{'end': 549.052, 'start': 488.108, 'title': 'Using pipenv for package management', 'summary': 'Explains how pipenv automatically updates packages, mitigates risks with pipfile.lock, allows specifying exact package versions, and setting python version for creating new environments.', 'duration': 60.944, 'highlights': ['Pipenv automatically updates packages, eliminating manual effort and ensuring access to newer versions.', 'Pipfile.lock mitigates the risk of updates breaking the project by ensuring package versions do not change unintentionally.', 'We can specify an exact version of the package in the pipfile, ensuring the project stays with that version even if a newer one is available.', 'Pipfile specifies the version of Python being used, allowing flexibility to change the version if needed for the environment.']}, {'end': 787.611, 'start': 549.632, 'title': 'Managing python environments with pipenv', 'summary': 'Covers the importance of pipfile.lock in ensuring a deterministic build, the activation of a virtual environment using pipenv shell, and the benefits of isolating project packages in a separate environment.', 'duration': 237.979, 'highlights': ['The pipfile.lock ensures a deterministic build, providing the exact same environment every time and only allowing a different build when explicitly updating the lock file.', 'Activating the virtual environment using pipenv shell isolates project packages, using a different Python interpreter and location for all packages, ensuring separation from other projects on the machine.', 'The importance of pipfile.lock in capturing dependencies and their exact versions, mitigating the risk of updating packages and breaking the project.']}], 'duration': 299.503, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/zDYL22QNiWk/pics/zDYL22QNiWk488108.jpg', 'highlights': ['Pipenv automatically updates packages, ensuring access to newer versions.', 'Pipfile.lock ensures a deterministic build, providing the exact same environment every time.', 'Pipfile specifies the version of Python being used, allowing flexibility to change the version if needed.', 'Activating the virtual environment using pipenv shell isolates project packages.']}, {'end': 1093.297, 'segs': [{'end': 812.904, 'src': 'embed', 'start': 788.251, 'weight': 0, 'content': [{'end': 793.794, 'text': "Okay, so now let's go ahead and exit out of Python here, and I'll go ahead and clear my screen.", 'start': 788.251, 'duration': 5.543}, {'end': 797.196, 'text': "So now let's say that we want to deactivate the environment.", 'start': 794.454, 'duration': 2.742}, {'end': 800.918, 'text': 'To deactivate the environment, we can simply say exit.', 'start': 797.776, 'duration': 3.142}, {'end': 807.401, 'text': 'Now there might be some confusion here that we used exit to deactivate the environment instead of using deactivate,', 'start': 801.318, 'duration': 6.083}, {'end': 810.483, 'text': 'which you might be used to using older virtual environments.', 'start': 807.401, 'duration': 3.082}, {'end': 812.904, 'text': 'now i was confused at this too.', 'start': 810.823, 'duration': 2.081}], 'summary': "Exiting python environment and deactivating environment using 'exit' instead of 'deactivate'.", 'duration': 24.653, 'max_score': 788.251, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/zDYL22QNiWk/pics/zDYL22QNiWk788251.jpg'}, {'end': 877.325, 'src': 'embed', 'start': 832.774, 'weight': 1, 'content': [{'end': 835.696, 'text': 'i know that can be a little confusing, but this is just how we do it.', 'start': 832.774, 'duration': 2.922}, {'end': 837.917, 'text': 'so now we no longer have that environment activated.', 'start': 835.696, 'duration': 2.221}, {'end': 841.66, 'text': 'Now we can actually run commands in our environment without activating it.', 'start': 838.357, 'duration': 3.303}, {'end': 844.782, 'text': 'So we can do that with the pipenv run command.', 'start': 842, 'duration': 2.782}, {'end': 850.526, 'text': "So let's say that I want to run Python within our current environment.", 'start': 845.142, 'duration': 5.384}, {'end': 855.87, 'text': 'So we could activate the environment like we just did with pipenv shell and then run Python.', 'start': 850.866, 'duration': 5.004}, {'end': 866.317, 'text': 'Or we could just simply say pipenv, run python and that will run that python command within that environment.', 'start': 856.691, 'duration': 9.626}, {'end': 877.325, 'text': 'so if i run that and check our executable again sys.executable then you can see that this python is using our virtual environment, python, and again,', 'start': 866.317, 'duration': 11.008}], 'summary': "Using 'pipenv', we can run commands in the environment without activating it, improving efficiency.", 'duration': 44.551, 'max_score': 832.774, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/zDYL22QNiWk/pics/zDYL22QNiWk832774.jpg'}, {'end': 963.102, 'src': 'embed', 'start': 938.409, 'weight': 5, 'content': [{'end': 947.072, 'text': "If you don't know what requirements.txt file is, basically it's just a list of dependencies and packages that a project needs in a little text file.", 'start': 938.409, 'duration': 8.663}, {'end': 955.577, 'text': 'So if you start using pipenv, you can still use your requirements.txt files before you completely switch over to using pip files.', 'start': 947.492, 'duration': 8.085}, {'end': 963.102, 'text': 'So for example, I have a requirements.txt file that has all of the dependencies that I use in my Django course.', 'start': 956.017, 'duration': 7.085}], 'summary': 'Requirements.txt lists project dependencies, can be used with pipenv before switching to pip files.', 'duration': 24.693, 'max_score': 938.409, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/zDYL22QNiWk/pics/zDYL22QNiWk938409.jpg'}, {'end': 1066.774, 'src': 'embed', 'start': 1040.734, 'weight': 3, 'content': [{'end': 1048.801, 'text': "Now, if you're using pipenv, but people on your team are still using pip, then you might need to create a requirements.txt file to send to them.", 'start': 1040.734, 'duration': 8.067}, {'end': 1056.467, 'text': "The pip command to display the list of dependencies that you'd use in a requirements.txt file is pip freeze.", 'start': 1049.502, 'duration': 6.965}, {'end': 1062.351, 'text': 'Now we can do the equivalent in pipenv by running the pipenv lock command.', 'start': 1056.827, 'duration': 5.524}, {'end': 1064.493, 'text': 'So let me show you this here.', 'start': 1062.371, 'duration': 2.122}, {'end': 1066.774, 'text': "So I'll pull back up my terminal.", 'start': 1064.653, 'duration': 2.121}], 'summary': 'Use pip freeze for pip, and pipenv lock for pipenv to create requirements.txt.', 'duration': 26.04, 'max_score': 1040.734, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/zDYL22QNiWk/pics/zDYL22QNiWk1040733.jpg'}], 'start': 788.251, 'title': 'Managing python environment with pipenv', 'summary': "Covers deactivating a virtual environment using the 'exit' command, the confusion around 'exit' and 'deactivate', running python commands within an environment using 'pipenv run python', installing multiple packages from an existing project using a requirements.txt file, transitioning from pip to pipenv, updating the pip file, importing dependencies, and creating a requirements.txt file for team members still using pip.", 'chapters': [{'end': 922.564, 'start': 788.251, 'title': 'Deactivating and running python environment', 'summary': "Discusses deactivating a virtual environment in python using the 'exit' command, highlighting the confusion around 'exit' and 'deactivate', and the method to run python commands within an environment using 'pipenv run python'.", 'duration': 134.313, 'highlights': ["Deactivating a virtual environment using 'exit' instead of 'deactivate', with explanation on the confusion and the need to use 'exit' to completely exit the environment.", "Running Python commands within an environment using 'pipenv run python', illustrating the option to run Python commands without activating the environment.", "Explanation on running scripts in the environment using 'pipenv run python script.py', showcasing the method to run scripts using the Python in the environment."]}, {'end': 1093.297, 'start': 922.944, 'title': 'Installing packages with pipenv', 'summary': 'Describes how to install multiple packages from an existing project using a requirements.txt file and demonstrates the transition from pip to pipenv, including updating the pip file, importing dependencies, and creating a requirements.txt file for team members still using pip.', 'duration': 170.353, 'highlights': ['Installing packages from a requirements.txt file using pipenv', 'Creating a requirements.txt file for team members using pip', 'Explanation of requirements.txt file and its usage with pipenv']}], 'duration': 305.046, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/zDYL22QNiWk/pics/zDYL22QNiWk788251.jpg', 'highlights': ["Deactivating a virtual environment using 'exit' instead of 'deactivate', with explanation on the confusion and the need to use 'exit' to completely exit the environment.", "Running Python commands within an environment using 'pipenv run python', illustrating the option to run Python commands without activating the environment.", "Explanation on running scripts in the environment using 'pipenv run python script.py', showcasing the method to run scripts using the Python in the environment.", 'Installing packages from a requirements.txt file using pipenv', 'Creating a requirements.txt file for team members using pip', 'Explanation of requirements.txt file and its usage with pipenv']}, {'end': 1691.552, 'segs': [{'end': 1158.335, 'src': 'heatmap', 'start': 1123.733, 'weight': 5, 'content': [{'end': 1131.495, 'text': "So for example, let's say that we're using PyTest to test our code, but we don't actually want PyTest included when we ship our code to production.", 'start': 1123.733, 'duration': 7.762}, {'end': 1138.16, 'text': 'So to do this, we can simply install a package like normal, but include the dev option on the end.', 'start': 1131.975, 'duration': 6.185}, {'end': 1144.085, 'text': 'So I could say pipenv install pytest dash dash dev.', 'start': 1138.48, 'duration': 5.605}, {'end': 1150.792, 'text': 'And if we run that, Then we can see that that installed like it normally would.', 'start': 1144.485, 'duration': 6.307}, {'end': 1155.074, 'text': "but there's a section here that says adding pytest to the pipfile's dev packages.", 'start': 1150.792, 'duration': 4.282}, {'end': 1158.335, 'text': "So let's go back to our pipfile and look at this.", 'start': 1155.454, 'duration': 2.881}], 'summary': 'Using dev option with pipenv to install pytest for testing without including it in production code.', 'duration': 26.36, 'max_score': 1123.733, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/zDYL22QNiWk/pics/zDYL22QNiWk1123733.jpg'}, {'end': 1249.75, 'src': 'embed', 'start': 1220.814, 'weight': 4, 'content': [{'end': 1226.777, 'text': 'So it turns out that instead of using Python 3.7, we actually needed to use Python 3.6.', 'start': 1220.814, 'duration': 5.963}, {'end': 1229.959, 'text': "Now, if we're using the old way of using virtual environments,", 'start': 1226.777, 'duration': 3.182}, {'end': 1235.822, 'text': 'then we might need to just export our requirements and then delete the environment and recreate it from scratch.', 'start': 1229.959, 'duration': 5.863}, {'end': 1238.884, 'text': 'But using pipenv is going to be a lot easier.', 'start': 1236.202, 'duration': 2.682}, {'end': 1242.426, 'text': 'uh, there are actually a couple of ways that we can do this.', 'start': 1239.404, 'duration': 3.022}, {'end': 1249.75, 'text': 'so the first way that we could do this is that we can just come in here into our pip file and change the version of python.', 'start': 1242.426, 'duration': 7.324}], 'summary': 'Switch to python 3.6 and use pipenv for easier environment management.', 'duration': 28.936, 'max_score': 1220.814, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/zDYL22QNiWk/pics/zDYL22QNiWk1220814.jpg'}, {'end': 1404.604, 'src': 'embed', 'start': 1381.469, 'weight': 6, 'content': [{'end': 1388.853, 'text': 'So to remove a virtual environment completely, we can simply say pipenv dash dash rm.', 'start': 1381.469, 'duration': 7.384}, {'end': 1396.777, 'text': 'So if we run that, we can see it says removing virtual environment and gives the location to the virtual environment that we just removed.', 'start': 1389.233, 'duration': 7.544}, {'end': 1404.604, 'text': 'now that only removes the environment that we were using, but everything that we need to recreate that environment is still within the pip file.', 'start': 1397.077, 'duration': 7.527}], 'summary': "To remove a virtual environment completely, use 'pipenv --rm' command, which removes the environment and retains the necessary files within the pip file.", 'duration': 23.135, 'max_score': 1381.469, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/zDYL22QNiWk/pics/zDYL22QNiWk1381469.jpg'}, {'end': 1493.257, 'src': 'embed', 'start': 1462.727, 'weight': 3, 'content': [{'end': 1465.349, 'text': 'Okay, so now let me clear the screen here.', 'start': 1462.727, 'duration': 2.622}, {'end': 1473.516, 'text': 'Now one really nice feature of pipenv is that we can easily check for known security vulnerabilities for any of our installed packages.', 'start': 1465.749, 'duration': 7.767}, {'end': 1482.768, 'text': 'So to do that we can simply say pipenv check and if I run that Then we can see that it discovered a couple of things here.', 'start': 1473.916, 'duration': 8.852}, {'end': 1487.632, 'text': 'So first it said checking PEP 508 requirements and that those passed.', 'start': 1483.108, 'duration': 4.524}, {'end': 1493.257, 'text': 'But then whenever it checked installed package safety, we got a couple of Django issues here.', 'start': 1488.273, 'duration': 4.984}], 'summary': 'Pipenv can check for security vulnerabilities; found issues in installed django packages.', 'duration': 30.53, 'max_score': 1462.727, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/zDYL22QNiWk/pics/zDYL22QNiWk1462727.jpg'}, {'end': 1584.687, 'src': 'embed', 'start': 1556.653, 'weight': 2, 'content': [{'end': 1560.276, 'text': "And we can see that when we run that check now that it says that we're all good.", 'start': 1556.653, 'duration': 3.623}, {'end': 1563.558, 'text': "So I think that's a really nice addition to pipenv.", 'start': 1560.676, 'duration': 2.882}, {'end': 1568.421, 'text': 'Now another feature of pipenv that I like a lot is pipenv graph.', 'start': 1564.058, 'duration': 4.363}, {'end': 1574.285, 'text': 'That will display a dependency graph showing your packages and the dependencies for each of those.', 'start': 1569.022, 'duration': 5.263}, {'end': 1577.187, 'text': "So let's clear the screen and run this.", 'start': 1574.665, 'duration': 2.522}, {'end': 1584.687, 'text': 'So if I say pipenv graph, So we can see here our packages and dependencies for those packages.', 'start': 1577.547, 'duration': 7.14}], 'summary': 'Pipenv check confirms all good; pipenv graph visualizes package dependencies.', 'duration': 28.034, 'max_score': 1556.653, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/zDYL22QNiWk/pics/zDYL22QNiWk1556653.jpg'}, {'end': 1631.087, 'src': 'embed', 'start': 1603.642, 'weight': 0, 'content': [{'end': 1610.329, 'text': "Okay so we're almost finished up but let me show you an example of what you do once you're ready to push your code to production.", 'start': 1603.642, 'duration': 6.687}, {'end': 1614.993, 'text': 'So currently our installs have been using the pip file to create our environment.', 'start': 1610.709, 'duration': 4.284}, {'end': 1620.659, 'text': "But if you remember I said that the pip file isn't deterministic but the pipfile.lock is.", 'start': 1615.314, 'duration': 5.345}, {'end': 1631.087, 'text': "So what I mean by that is that the pipfile.lock has the exact hashes and versions for specific packages that we're currently using in our project,", 'start': 1621.099, 'duration': 9.988}], 'summary': 'Using pipfile.lock ensures deterministic package versions for production deployment.', 'duration': 27.445, 'max_score': 1603.642, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/zDYL22QNiWk/pics/zDYL22QNiWk1603642.jpg'}, {'end': 1670.018, 'src': 'embed', 'start': 1640.332, 'weight': 1, 'content': [{'end': 1646.075, 'text': "we want to know that we're pushing the exact versions of the packages that have already passed all of our testing.", 'start': 1640.332, 'duration': 5.743}, {'end': 1650.718, 'text': "So, once you've tested all of your code and you know that you're ready to push what you have so far,", 'start': 1646.395, 'duration': 4.323}, {'end': 1659.374, 'text': 'then you can create or update the pipfile.lock with the current dependencies, by saying pipenv lock.', 'start': 1651.198, 'duration': 8.176}, {'end': 1664.054, 'text': 'And we can see that it says that it updated that pipfile.lock.', 'start': 1660.771, 'duration': 3.283}, {'end': 1670.018, 'text': "So once that's done, then you can take your pipfile.lock and move it to your production environment.", 'start': 1664.554, 'duration': 5.464}], 'summary': 'Ensure pushing tested package versions using pipenv lock for production.', 'duration': 29.686, 'max_score': 1640.332, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/zDYL22QNiWk/pics/zDYL22QNiWk1640332.jpg'}], 'start': 1093.297, 'title': 'Using pipenv for package management and security', 'summary': 'Covers using pipenv for package management, including installing and uninstalling packages, managing dependencies with different python versions, checking for security vulnerabilities, updating package versions, visualizing dependency graphs, and creating a deterministic environment for production using the pipfile.lock.', 'chapters': [{'end': 1462.346, 'start': 1093.297, 'title': 'Using pipenv for package management', 'summary': 'Discusses using pipenv for package management, including installing packages in dev environment, uninstalling packages, and recreating virtual environments using different python versions and the pip file.', 'duration': 369.049, 'highlights': ['Recreating a virtual environment using a different Python version is easier with Pipenv compared to the old way of using virtual environments', "Installing a package only in a dev environment using the 'dev' option, such as 'pipenv install pytest --dev'", 'Removing a virtual environment completely and recreating it from scratch using the pipfile']}, {'end': 1691.552, 'start': 1462.727, 'title': 'Managing packages with pipenv', 'summary': 'Discusses using pipenv to check for security vulnerabilities, update package versions, visualize dependency graph, and create a deterministic environment for production using the pipfile.lock.', 'duration': 228.825, 'highlights': ['Using pipenv check to identify security vulnerabilities and resolve package issues', 'Updating package versions in pipfile and installing changes with pipenv install', 'Visualizing dependency graph with pipenv graph', 'Creating deterministic environment for production using pipfile.lock']}], 'duration': 598.255, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/zDYL22QNiWk/pics/zDYL22QNiWk1093297.jpg', 'highlights': ['Creating a deterministic environment for production using pipfile.lock', 'Updating package versions in pipfile and installing changes with pipenv install', 'Visualizing dependency graph with pipenv graph', 'Using pipenv check to identify security vulnerabilities and resolve package issues', 'Recreating a virtual environment using a different Python version is easier with Pipenv compared to the old way of using virtual environments', "Installing a package only in a dev environment using the 'dev' option, such as 'pipenv install pytest --dev'", 'Removing a virtual environment completely and recreating it from scratch using the pipfile']}, {'end': 1935.648, 'segs': [{'end': 1735.418, 'src': 'embed', 'start': 1692.372, 'weight': 0, 'content': [{'end': 1694.173, 'text': "OK, so we're almost finished up here.", 'start': 1692.372, 'duration': 1.801}, {'end': 1696.294, 'text': 'There is one more thing that I wanted to show,', 'start': 1694.693, 'duration': 1.601}, {'end': 1700.696, 'text': "because it's something that I personally look for when working with tools that create virtual environments.", 'start': 1696.294, 'duration': 4.402}, {'end': 1706.898, 'text': 'And that is the ability to set environment variables that are specific to the environment.', 'start': 1701.156, 'duration': 5.742}, {'end': 1711.64, 'text': "Now, this is something that some tools overlook, but I think it's extremely important.", 'start': 1707.278, 'duration': 4.362}, {'end': 1712.821, 'text': 'So, for example,', 'start': 1712.02, 'duration': 0.801}, {'end': 1725.23, 'text': "if you're working on multiple Flask or Django projects and want to have environment variables for each project that contain the project secret key and database connection information and things like that,", 'start': 1712.821, 'duration': 12.409}, {'end': 1730.774, 'text': 'then it would be nice to have the virtual environment handle this without needing to do that manually.', 'start': 1725.23, 'duration': 5.544}, {'end': 1735.418, 'text': 'So the way that we can do this using pipenv is to create a .', 'start': 1731.075, 'duration': 4.343}], 'summary': 'Importance of setting environment variables for virtual environments using pipenv for multiple flask or django projects.', 'duration': 43.046, 'max_score': 1692.372, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/zDYL22QNiWk/pics/zDYL22QNiWk1692372.jpg'}, {'end': 1906.501, 'src': 'embed', 'start': 1844.002, 'weight': 1, 'content': [{'end': 1851.644, 'text': "So for example, Flask and Django projects are most likely all going to have secret keys, and you don't want to manage all of those manually.", 'start': 1844.002, 'duration': 7.642}, {'end': 1854.185, 'text': "It's better to just put them in a .", 'start': 1851.744, 'duration': 2.441}, {'end': 1856.868, 'text': 'env file specific to that project.', 'start': 1854.185, 'duration': 2.683}, {'end': 1861.111, 'text': 'Now another thing is that you do not want to commit those .', 'start': 1857.208, 'duration': 3.903}, {'end': 1864.495, 'text': 'env files to your repository.', 'start': 1861.111, 'duration': 3.384}, {'end': 1870.1, 'text': "So if you're using Git or something like that, then you're most likely going to want to add that .", 'start': 1864.835, 'duration': 5.265}, {'end': 1876.086, 'text': "env file to your gitignore file because you don't want to commit it for other people to see,", 'start': 1870.1, 'duration': 5.986}, {'end': 1883.314, 'text': 'because it could possibly have sensitive information like database connection strings and passwords and things like that.', 'start': 1876.086, 'duration': 7.228}, {'end': 1884.956, 'text': 'So just a tip.', 'start': 1883.974, 'duration': 0.982}, {'end': 1890.422, 'text': "That's something that I use a lot is those environment variables within different projects.", 'start': 1884.996, 'duration': 5.426}, {'end': 1892.804, 'text': 'Okay, so I think that is going to do it for this video.', 'start': 1890.922, 'duration': 1.882}, {'end': 1898.251, 'text': 'Hopefully now you have a good idea for how pipenv works and how you can start using it on your projects.', 'start': 1893.105, 'duration': 5.146}, {'end': 1906.501, 'text': 'I actually like this tool a lot and will most likely be using it instead of pip and virtualenv for most projects from here on out.', 'start': 1898.852, 'duration': 7.649}], 'summary': 'Use .env files for secret keys and sensitive info, add to gitignore to protect sensitive data.', 'duration': 62.499, 'max_score': 1844.002, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/zDYL22QNiWk/pics/zDYL22QNiWk1844002.jpg'}], 'start': 1692.372, 'title': 'Setting environment variables and .env files', 'summary': 'Highlights the importance of setting environment variables in virtual environments using .env files in pipenv for multiple flask or django projects, and discusses the benefits of using .env files to store sensitive information and the advantages of using pipenv over pip and virtualenv.', 'chapters': [{'end': 1827.319, 'start': 1692.372, 'title': 'Setting environment variables in virtual environments', 'summary': 'Highlights the importance of setting environment variables specific to virtual environments, using .env file in pipenv to store environment variables for multiple flask or django projects, and accessing the environment variables within the python environment.', 'duration': 134.947, 'highlights': ['The ability to set environment variables specific to the virtual environment is important when working with tools that create virtual environments.', 'Using a .env file in pipenv allows storing environment variables for multiple Flask or Django projects, such as project secret keys and database connection information.', 'Accessing the environment variables within the Python environment can be done using the OS module and os.environ, enabling easy retrieval of the stored environment variables.']}, {'end': 1935.648, 'start': 1827.719, 'title': 'Using environment variables with .env files', 'summary': 'Discusses the use of .env files to store sensitive information like secret keys and database connection strings, and the importance of using them to manage multiple projects efficiently, and the benefits of using pipenv over pip and virtualenv.', 'duration': 107.929, 'highlights': ['The use of .env files to store sensitive information like secret keys and database connection strings is important for managing multiple projects efficiently.', "It's better to put sensitive information in a .env file specific to each project and not commit these files to the repository, especially when using Git, to avoid exposing sensitive information like database connection strings and passwords.", 'The benefits of using pipenv over pip and virtualenv for most projects include efficiency and ease of use, and it is recommended to learn and use pipenv as many others are doing the same.']}], 'duration': 243.276, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/zDYL22QNiWk/pics/zDYL22QNiWk1692372.jpg', 'highlights': ['Using a .env file in pipenv allows storing environment variables for multiple Flask or Django projects, such as project secret keys and database connection information.', 'The use of .env files to store sensitive information like secret keys and database connection strings is important for managing multiple projects efficiently.', 'The benefits of using pipenv over pip and virtualenv for most projects include efficiency and ease of use, and it is recommended to learn and use pipenv as many others are doing the same.', "It's better to put sensitive information in a .env file specific to each project and not commit these files to the repository, especially when using Git, to avoid exposing sensitive information like database connection strings and passwords.", 'The ability to set environment variables specific to the virtual environment is important when working with tools that create virtual environments.']}], 'highlights': ['Pipenv simplifies package management and virtual environment handling, favored by many teams and companies as an alternative to pip and virtualenv.', 'Pipenv automatically updates packages, ensuring access to newer versions.', 'Pipenv automatically creates a virtual environment, installs packages, and creates a PIP file, streamlining the process of managing project dependencies.', 'Creating a deterministic environment for production using pipfile.lock', 'Virtual environments provide project-specific environments for Python and package versions, preventing conflicts and issues when updating Python or packages.', "Pipenv installation can be done easily using 'pip install pipenv', simplifying the process of combining package management and virtual environments.", 'Pipfile.lock ensures a deterministic build, providing the exact same environment every time.', "Instructions for activating the new virtual environment using 'pipenv shell' and running commands within it with 'pipenv run'.", 'Using a .env file in pipenv allows storing environment variables for multiple Flask or Django projects, such as project secret keys and database connection information.', 'The use of .env files to store sensitive information like secret keys and database connection strings is important for managing multiple projects efficiently.']}