Python PIP
Pip - Python Package Installer
PIP, the Package Installer for Python, is a command-line tool that allows you to install, manage, and uninstall Python packages from the Python Package Index (PyPI). PyPI is a repository of software packages developed and maintained by the Python community. PIP simplifies the process of installing and managing external libraries and packages for Python development.
Basic PIP Commands:
- Install a Package:
- Install a Specific Version:
- Install from Requirements File:
- Show Installed Packages:
- Upgrade a Package:
- Uninstall a Package:
pip install package_name
pip install package_name==version_number
pip install -r requirements.txt
pip list
pip install --upgrade package_name
pip uninstall package_name
Virtual Environments:
It's often recommended to use virtual environments to isolate project dependencies. Here's how you can create and activate a virtual environment:
- Create a Virtual Environment:
- Activate the Virtual Environment:
- On Windows:
- On Unix or MacOS:
- Deactivate the Virtual Environment:
python -m venv myenv
myenv\Scripts\activate
source myenv/bin/activate
deactivate
Examples:
- Installing Flask:
pip install Flask
pip install Flask==2.0.1
pip install -r requirements.txt
pip install --upgrade Flask
pip uninstall Flask
Pip is an essential tool for Python development, and it plays a crucial role in managing dependencies for your projects. Using virtual environments with PIP helps ensure that your projects have the required dependencies without affecting the system-wide Python installation.