Project Setup for Python 2 AND 3 [with Virtualenv]

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
here I have opened up a folder on my computer with vs code and we can see that inside of this folder there exists one file called readme.md when we're done with this walkthrough you can take the final boilerplate project and choose to use it to build your own python applications you will tweak this readme file to contain information and documentation that is relevant to the application that you create I prefer not to have one huge readme file at the root of my project but instead have smaller readme files for organizational purposes I put each readme file inside of the readme's folder right now the readme's folder has one readme with information that I will use to guide me as I set up this first python project we already have python installed you already have Pip installed so let's install our first third-party package virtual MV I already have it installed let's verify the version the reason that we need virtual m is that python by default installs packages globally on our system this means that if we have two projects on our computer that use the same third-party package but require different versions of the third party package we won't be able to run both apps at the same time for example let's say that we have project and our computer that uses a third-party package called awesome package but uses version six let's say that we also have Project B on our computer but Project B uses awesome package versus seven when referencing packages from our python code we can only specify the name of the package not the version so an issue will arise when running either Project A or B because one of them will not be referencing the version of the package it needs so what virtual M does is set up our project to not install and use packages globally but instead set us up to install and use packages within our project folder this then allows each project on our computer to use its preferred versions of packages without affecting other projects here is how we can use VMV this command is how we can create a folder in our project that will house all of the Python packages we install the final argument of this command is the name of the folder that we want to use you can call it whatever you want but by convention it is called the VM folder the next thing to do is configure our terminal or our shell to configure pip to install whatever packages we choose to install in our project into this VM folder and we do that with this command if this command was successful you should see that your terminal prompt has changed to this before it was this now it is this let's smoke test everything to make sure that we're on the right track we're creating a file called main.py let's throw some code into that file and let's execute the main.py file and we can see that hello world has been printed now let's run this command python main.py without the three and we can see it works another thing that VM does is Alias the python command to whatever version of python you have installed in your project let's develop this main.py file to be a little bit more intricate now let's use these packages and the app we are about to develop pandas and matplotlib and we are going to graph some temperature data let's throw some temperature data into this file come back to our readme and let's copy our new program into main.py save that let's run main.py voila let's close that let me just show you two more things the first of the last two things being bookkeeping of the third party packages we have installed into our application if you are familiar with node.js or Ruby on Rails then you know about the package.json or gem files these are files that record all of the third-party packages we have installed into our application pip or python does not do this by default we have to manually execute this as another step pip freeze will spit out all of the third party packages as well as their versions and the second half of this command will pipe this into a file that is conventionally named requirements.txt the second of the last two things is regarding the dot get ignore in node.js development you do not store the node modules folder into revision control and in Python development you do not store the VM folder into revision control so let's add a DOT get ignore and I will copy this suggested dot get ignore file from GitHub and paste it into our project actually let me show you one last thing and that is what the reactivation process would look like so if we type deactivate we see that we are now outside or have exited our virtual environment right so if you wanted to collaborate on this project with a friend for example they would not get the VM folder they would get something like this right this is what they would clone and they would run the project like so they would hopefully already have Python pipped and virtual M installed they would generate the VM folder they would activate their shell you can see that the terminal prompt has changed and then they would reinstall all of the packages listed in the requirements.txt file
Info
Channel: COMMAND
Views: 696
Rating: undefined out of 5
Keywords:
Id: dC1A8t-G3tw
Channel Id: undefined
Length: 7min 14sec (434 seconds)
Published: Wed Dec 28 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.