Install and create packages in python

Опубликовано: 05 Декабрь 2022
на канале: Developer Bites
7
1

The python package installer pip is used to install packages in python. the syntax for usage of pip command is almost the same for the three major operating systems - Linux, Mac and Windows.

At first activate a python virtual environment and update the pip installer
pip install --upgrade pip setuptools wheel

Install the package:

pip install your-package-name

For example,

pip install requests

For specific version:

pip install "django==3.2"

To create a simple package for your local use, just create a directory with a meaningful name and create an empty file with name __init__.py inside the directory.

Create a module file , for example, my module.py and create functions and classes in the file. After completion, you can import this package in your local project.