Python PIP 📦
Package Management
PIP is the standard package manager for Python. It allows you to install and manage additional libraries and dependencies that are not part of the Python standard library.
🛍️ Analogy: The App Store
Think of PIP as the App Store for Python.
- Python comes with some built-in apps (Standard Library).
- But if you want to do Data Science (NumPy) or Web Scraping (Requests), you need to download those "apps" from the store using PIP.
✨ Basic Commands
# Install a packagepip install requests# Uninstall a packagepip uninstall requests# List installed packagespip list# Show package detailspip show requests
📜 Requirements Files
It is common practice to list all project dependencies in a requirements.txt file. This allows others to install all necessary packages with a single command.
# Create requirements.txtpip freeze > requirements.txt# Install from requirements.txtpip install -r requirements.txt
🔍 Finding Packages
You can find thousands of open-source packages on the Python Package Index (PyPI).
💡 Virtual Environments
It is highly recommended to use a virtual environment to keep dependencies required by different projects separate.
# Create a virtual environmentpython -m venv myenv# Activate (Windows)myenv\Scripts\activate# Activate (Mac/Linux)source myenv/bin/activate
✨ Pro Tip: Upgrade PIP
If you get a warning that your PIP version is old, you can upgrade it using:
python -m pip install --upgrade pip