When writing real-world Python applications, you will need to install external packages, manage project environments, and write code in suitable editors.
PIP is the standard package manager for Python. It allows you to download and install packages from PyPI (Python Package Index).
- Check if PIP is installed:
pip --version
- Install a package:
pip install package_name
- List installed packages:
pip list
- Uninstall a package:
pip uninstall package_name
Virtual environments are self-contained directory trees that contain a copy of Python and standard tools, isolating your project dependencies from other projects on your computer.
Navigate to your project directory in the terminal and run:
python -m venv myenv- On Windows (PowerShell):
.\myenv\Scripts\Activate.ps1
- On macOS/Linux:
source myenv/bin/activate
Once activated, any pip install commands run exclusively inside this environment. To exit, type:
deactivateTo share your project with others or deploy it, you need to document the packages it uses.
- Generate
requirements.txt(freeze current environment packages):pip freeze > requirements.txt - Install dependencies from
requirements.txt:pip install -r requirements.txt
In modern Python packaging, pyproject.toml (defined in PEP 518) is the standardized configuration file for build tools, dependencies, and code formatter settings (like Black, Ruff, or Flake8).
To write Python code efficiently, it is recommended to use a dedicated Integrated Development Environment (IDE) or text editor:
- Visual Studio Code (VS Code): A lightweight, powerful editor with excellent Python support via the official Microsoft Python extension.
- PyCharm: A full-featured IDE developed by JetBrains specifically for Python development.