Рет қаралды 14,902
Follow me on Twitter:
in...
Hello friends, in this video I'm going to be showing you my favourite way to install python modules.
I will be showing you how to install compatible versions of django, djangorestframework and pytest.
Django is a python framework for web development and pytest is a framework for testing our python code.
We're going to start by setting up a virtual environment. Then we're going to go ahead and activate the virtual environment.
Our virtual environmment is now activated as you can see here. Anything we install will only be available inside the virtual environment.
Normally people install python packages with pip install like this
This would install a python module called pytest.
However if we wanted to install multiple things that need compatible versions to work this would be difficult.
Instead we can use this amazing package called pip-tools which we're going to use to install all of the packages we need to be compatible.
We can install this with pip like so.
Then we're going to create a requirements.in file. Inside here we're going to list all of the modules we want.
I want to specify that I want django==3.1 like so. But we also want to install compatible versions of djangorestframework and pytest .
We can then exit and save.
We will now use pip-tools, and we'll create a requirements.txt file with the following command:
This creates a new file called requirements.txt which tells us which versions of software for each of these modules to install.
Then all we have to do to download these is the following command.
And just like that we have all of our python modules installed and we already know they will be compatible with each other.
We can now check that django is installed.
And that's it for this video, so hopefully that was useful, you'd now be able to set up your django project and use pytest and use djangorestframework.
Thank you for watching.