Here we use a virtual environment self-contained directory tree that contains a Python installation for a particular version of Python, plus several additional packages. each application, you can use a different virtual environment and make your work easier.
Create a Virtual Environment
If you are using Python3 then you will already have venv in your system otherwise you should install it by using the pip command in the shell
python -m pip install virtualenvwrapper-win
Create a directory where you want to work with
mkdir foldername
create a virtual environment there by running venv module as a script with the directory module.
mkvirtualenv name
This will create a virtual environment with a name as 'name'. After creating the environment you can work specifically on your application.
Note: When you restart your shell your virtual environment will be closed you have to restart it with the respective command to again start your virtual environment.
Manage packages using pip
You can install, upgrade, and also remove the packages using pip command. By default, pip will install the packages from the python index. pip can also be used to search the packages from the python index, it will give you package name and version with it.
pip has many commands like install, uninstall, freeze, search, etc.(Go through the installing pip for more information)
pip install djangopip install django == 3.0.6pip install --upgrade django
If the package is already installed in your system it shows that requirements are satisfied and you can update the version also.
pip uninstall followed by the package name will uninstall that package.
pip list will tell you the number of packages in the virtual environment.
pip show followed by the package name will tell you the features of the package.
pip show Django
Name: Django
Version: 3.0.6
Summary: A high-level Python Web framework that encourages rapid development and clean, pragmatic design.
Home-page: https://www.djangoproject.com/
Author: Django Software Foundation
Author-email: foundation@djangoproject.com
License: BSD
Location: c:\users\balus\envs\django\lib\site-packages
Requires: sqlparse, pytz, asgiref
Required-by: django-urls
pip has many more options you can go through installing pip and get more info. You can also create a package.
No comments