Python Modules, pip and Virtual Environments (venv) Explained for Beginners
P10.3 How to Install Python Packages with pip
Why. pandas, NumPy and matplotlib are not built in. pip downloads them from PyPI, the Python package library.
What. pip is the Python package installer. Common commands:
| Command | What it does |
|---|---|
| python -m pip install pandas | install a package |
| python -m pip install pandas==2.2.2 | install an exact version |
| python -m pip install --upgrade pandas | upgrade |
| python -m pip list | show installed packages |
| python -m pip uninstall pandas | remove |
How to read this table: each row is one pip command and what it does. Mac users type python3.
How.
Install the data science basics
- Open the terminal (activate your venv first — next section).
- Run
python -m pip install numpy pandas matplotlib. - Wait for "Successfully installed".
- Check with a quick import.
Worked example A — Install packages.
Step 1 — What we do. We install the three core libraries in one command.
Step 2 — Type and run this code.
python -m pip install numpy pandas matplotlib
Step 3 — Output you should see.
Successfully installed numpy-2.1.0 pandas-2.2.2 matplotlib-3.9.2 ...
Step 4 — What it means. pip installs each package plus the packages they need.
Worked example B — Check the installed version.
Step 1 — What we do. We confirm NumPy works and see its version.
Step 2 — Type and run this code.
import numpy
print(numpy.__version__ >= "1")
Step 3 — Output you should see.
True
Step 4 — What it means. __version__ holds the version text. If import fails, the package is not installed in this Python.
Worked example C — Install from inside Jupyter.
Step 1 — What we do. In a notebook cell, the %pip magic installs into the notebook's own Python.
Step 2 — Type and run this code.
%pip install seaborn
Step 3 — Output you should see.
Successfully installed seaborn-0.13.2
Note: you may need to restart the kernel to use updated packages.
Step 4 — What it means. Use %pip (not !pip) inside Jupyter so the package lands in the right Python. Then restart the kernel.
Ravindra Bagale's Tip
Only install packages from names you trust. Check spelling carefully — fake look-alike package names exist.
Ravindra Bagale's Tip – मराठी
फक्त विश्वासार्ह नावांचे packages install करा. Spelling नीट तपासा — सारखी दिसणारी बनावट package नावं असतात.
Ravindra Bagale's Tip – हिंदी
सिर्फ़ भरोसेमंद नामों के packages install करो. Spelling ध्यान से check करो — मिलते-जुलते नकली package नाम होते हैं.