Introduction
If you’re new to coding and want to try Python, this guide will help you set up everything step by step. We’ll use PowerShell as the main command console for running Python scripts. This guide is designed for absolute beginners, so no prior knowledge is needed!
Step 1: Install PowerShell (If Not Already Installed)
PowerShell comes pre-installed on Windows 10 and later, but if you need the latest version, follow these steps:
- Download PowerShell from the official Microsoft page: PowerShell Releases
- Choose the MSI package for Windows and install it.
- After installation, open PowerShell by searching for “PowerShell” in the Windows Start menu.
- To check if PowerShell is working, type:
$PSVersionTable.PSVersion
This should display the PowerShell version installed on your system.
Step 2: Install Python
To install Python, follow these steps:
- Download Python from the official website: Python Downloads
- Choose the latest stable version for Windows.
- During installation, check the box “Add Python to PATH” (important!).
- After installation, verify Python by running:
python --version
or
py --version
This should display the installed Python version.
Additional Recommended Tools
- pip: Installed with Python (used for installing additional packages).
- virtualenv: Helps manage Python environments.
pip install virtualenv
- Git (optional but useful): Download from Git for Windows
Step 3: Understanding Python Installation Types
Python installations can be system-wide or folder-specific. Here’s a breakdown:
Type | Description |
---|---|
System-wide installation | Python is installed for all users. Any script can use it. |
Virtual environment (folder-based) | A self-contained Python setup inside a specific folder. Useful for project-specific dependencies. |
To create a folder-specific virtual environment:
python -m venv my_project_env
To activate it:
my_project_env\Scripts\Activate
To deactivate it:
deactivate
Step 4: Running Python Scripts in PowerShell
- Running a script in the current folder:
python script.py
This runs
script.py
inside the current folder. - Running a script inside a virtual environment:
my_project_env\Scripts\Activate python script.py deactivate
- Running a script from another folder:
python C:\path\to\script.py
Comparison of Python, PowerShell, Git & Virtual Environment
Tool | Use Case | Why Use It? |
---|---|---|
Python | General-purpose programming language for scripting, automation, web development, and more. | Essential for coding, data analysis, and automation. |
PowerShell | Command-line shell and scripting language for system automation on Windows. | Helps automate system tasks and manage configurations. |
Git | Version control system used for tracking code changes and collaboration. | Prevents code loss, supports teamwork, and tracks modifications. |
Virtual Environment | Isolated Python environment for managing dependencies per project. | Avoids conflicts between projects with different dependencies. |
Conclusion
You now have Python set up and ready to use with PowerShell! Try writing your first Python script and running it with python script.py
. Happy coding!