|
Image Credit: Debiprasad |
High-level Python web framework Django promotes quick development and streamlined, practical design. It was created by seasoned programmers and handles a lot of the fuss associated with web development, freeing you up to concentrate on writing your app without having to invent the handlebars. It is open source and free.
So let's talk about how to use Windows 11's Command Prompt(CMD/terminal) to install Django and establish a virtual environment.
1. Installing Python
I) Click here to go to the Python Download page. Once the page has opened, go to Download > Windows.
II) Select option "Download Windows installer" under "Stable Releases" on the following page. (You can download the 32-bit or 64-bit according to your system.) Your download will start shortly.
III) Open the installer you just downloaded to install Python after the download is complete. Choose the default drive that Python has already chosen in order to avoid future issues. Please remember to check the box "Add Python 3.10 to PATH".(v3.10 is merely a version indicator. It may be different in your instance.)
IV) The installation of Python on your computer will begin.
V) Click on close once the installation is complete. Python has now been installed on your computer and is ready for use. 2. Installing pipenv
I) Open your command prompt/CMD. If you are in a separate user directory, navigate to your primary C directory by typing cd/ command. Then press enter.
II) Once you're in your main directory, perform the command python -m pip install pipenv and press enter.
Note: If the message "A new release of pip available" appears, use the command python -m pip install --upgrade pip to update it to the most recent version.
III) Wherever you wish to put your virtual environment, create a new folder. Type md Your Folder Name or mkdir Your Folder Name to create a new folder and to access the directory/folder type cd followed by the name of your folder you just created.
Example: Suppose, in my case I'll type md Dev or mkdir Dev, but you can type any name after md/mkdir. Then to access it I'll type cd Dev.
Using the same process create another directory inside the directory you just created.
Example: For my case, I'll type md venv to create the directory and then cd venv to access the directory.
3. Creating virtual environment and activating it
I) It's time for us to create the virtual environment now. Enter the command pipenv install. This command will start creating a virtual environment for your project.
II) Let's activate the virtual environment. To activate it type pipenv shell.
I) For installing Django run the command pipenv install Django and then it will start installation of Django.
II) Type python -m django --version to check the current django version to see if the installation was successful or not.
III) You can now properly quit the virtual environment after installing Django by typing exit command.
Congratulations! You've successfully created a virtual environment and installed Django. You can now develop your project using Django frameworks.
Please feel free to ask us any question(s) in the comments section if you need any help with any of the above-described stages. Without a doubt, we'll communicate with you as soon as possible.
Thank you