
Python — Execution Environment & Runtime Diagnosis

Why Python?
Python supports web services, data analysis, research and automation. This course is a structured review: readable syntax does not remove the need to understand state, failure conditions and environment differences.
CPython compiles source into bytecode before executing it. Running Python without a separate compilation command is not evidence that compilation never occurs. See the official bytecode definition.
As checked on 2026-10-03, Python 3.10 reached end of support on 2026-10-01; Python 3.11 is in security maintenance. Choose a supported Python 3 version compatible with project dependencies, not merely any Python 3 version. Consult the version status table and Python 3.10 lifespan.
Installation
Use official downloads and the instructions for your platform. Windows Install Manager and the older installer have different workflows; PATH configuration is not a universal mandatory checkbox. The py launcher or a full executable path can also select an interpreter. Apple development-tool Python on macOS is not necessarily the Python intended for your project. Do not delete or overwrite the system-managed interpreter.
Verify the runtime with python --version or the command your installation provides. In VS Code, install Microsoft’s Python extension and select the project interpreter. The editor, terminal and notebook can otherwise execute different runtimes. Distribution bundles are an alternative, not a prerequisite or a guarantee that every required library is installed.
Platform details: Windows, older Windows installer, macOS.
pip: Package Management
Official binary installers normally include pip, but distributions and installation options can differ. Invoke pip through the intended interpreter. Installation commands change that environment; confirm the target first.
python -m pip --version
python -m pip install requests
python -m pip install pandas numpy matplotlib
python -m pip list
python -m pip install -r requirements.txt
Use package==version when a project’s compatibility policy requires a specific version. python -m pip freeze > requirements.txt records installed versions in requirements format and overwrites that file; review the result before replacing an existing file. It does not capture the operating system, Python runtime or external data. See pip installation conditions.
Virtual Environments
Create one project environment, then reuse it:
python -m venv myenv
Windows CMD activation:
myenv\Scripts\activate.bat
bash/zsh activation on macOS or Linux:
source myenv/bin/activate
When finished, use deactivate. Standard venv separates base-environment packages by default, unless created with --system-site-packages. It is not a file, network or security sandbox. See venv.
Runtime diagnosis
Run this where the failure occurs. It reads runtime information without installing packages or modifying files:
import sys
print("Executable:", sys.executable)
print("Python version:", sys.version.split()[0])
print("Environment:", sys.prefix)
print("Base environment:", sys.base_prefix)
print("Standard venv:", sys.prefix != sys.base_prefix)
Paths vary by machine. The prefix comparison detects standard venv use, not every environment manager. If installation succeeds but import fails, compare the executable in the editor and terminal, check pip in that environment, and look for local files that shadow a package name.
First output and REPL
print("Hello, World!")
Output:
Hello, World!
The interactive prompt >>> is not copied into a script. Comments begin with #; triple-quoted strings are string literals and can serve as docstrings in specific positions, not a multiline-comment syntax.
Chapter 2 Preview
Next: Names, Types, Strings & Conversion.
OIYO Editorial
Editorial DeskThe OIYO editorial desk researches money, law, lifestyle, and self-understanding topics against primary sources and public statistics. Every piece carries source notes and is reviewed on a regular cycle for accuracy and usefulness.