Loading Page Content...
Preparing courses, live labs, and learning resources.सामग्री लोड हो रही है, कृपया प्रतीक्षा करें...
Preparing courses, live labs, and learning resources.सामग्री लोड हो रही है, कृपया प्रतीक्षा करें...
In the previous lesson, we installed VS Code and learned how to run a Python program.
Now let's make sure Python is properly installed and understand a few important tools that you will use throughout this course.
In this lesson, we will learn:
.venvDon't worry if these terms sound new.
We will understand each one step by step.
Think about Python like a tool that you want to use from anywhere on your computer.
Installing Python puts the tool on your computer.
But your computer also needs to know where that tool is located.
This is where PATH becomes useful.
The basic idea is:
PATH is an environment variable used by your operating system.
It contains a list of folders where the operating system looks for executable programs.
You don't need to remember the technical definition.
Think of PATH as a list of addresses.
Imagine you want to visit your friend's house.
You know your friend's name, but you also need to know their address.
Similarly:
PATH helps your computer find that location.
So when you type:
your operating system can look through the locations listed in PATH and find Python.
During Python installation on Windows, you may see an option such as:
If you see this option, it is a good idea to enable it before installing Python.
This makes it easier to use Python from Command Prompt or PowerShell.
python in the terminal.After installing Python, open:
Then type:
You may see something like:
Your version may be different.
That's completely normal.
means we want to use Python.
means we want to know which Python version is installed.
So:
simply means:
Sometimes you may type:
and receive an error such as:
Don't panic.
This usually means one of these things:
We will learn how to troubleshoot these situations during the setup process.
When you install Python, you get the Python language and tools needed to run Python programs.
But sometimes your project needs additional libraries.
For example, you may want to work with:
Instead of writing everything from scratch, Python developers often use packages.
pip is a commonly used tool for installing and managing Python packages.
For example:
This command tells Python to use pip to install the requests package.
We will learn package installation in more detail later.
Python packages are commonly published through PyPI.
PyPI stands for:
Python Package Index
Think of PyPI as a large online collection of Python packages.
A simple way to remember it:
pip as one of the tools you use to get those packages.REPL stands for:
Read → Eval → Print → Loop
The name may sound difficult, but the idea is very simple.
The Python REPL lets you type a Python instruction and immediately see the result.
It's like a Python playground.
Open your terminal and type:
You may see something similar to:
The:
symbol means Python is ready for your instruction.
Now try:
Python will immediately show:
Try another example:
Output:
REPL is useful when you want to quickly test something.
For example:
Output:
You don't need to create a .py file just to test a small calculation.
To leave the Python REPL, you can type:
and press Enter.
You can also use:
On Windows, another option is:
followed by Enter.
On macOS/Linux:
exit(). It is the easiest option.A package is a collection of Python code that provides functionality you can use in your own project.
For example, instead of creating every tool yourself, you can use an existing package.
Imagine you are building a house.
You don't manufacture every:
yourself.
You use ready-made components.
Python packages work in a similar way.
A virtual environment is a separate environment for a Python project.
It allows a project to have its own installed packages instead of depending entirely on packages installed globally on the computer.
Imagine you have two projects:
If everything is installed globally, different projects can sometimes require different package versions.
A virtual environment helps keep their dependencies separate.
Let's create one.
Open your terminal inside your project folder.
Run:
This creates a folder named:
inside your project.
Your project may now look like:
The command depends on your operating system.
After activation, you may see something like:
at the beginning of your terminal prompt.
For example:
This tells you that the virtual environment is active.
When you are finished working with the virtual environment, you can deactivate it by typing:
The (.venv) label should disappear from the terminal prompt.
You may be thinking:
.venv for every small Python program?"Not necessarily.
For very simple practice programs, you can learn Python without creating a virtual environment every time.
However, when you start working on real projects and installing packages, virtual environments are a very useful habit.
Let's make sure everything is working.
You should see a Python version.
You should see information about pip.
You should see:
Try:
Expected result:
Inside your project folder:
Keep this small cheat sheet for revision.
| Task | Command |
|---|---|
| Check Python version | python --version |
| Check pip | python -m pip --version |
| Start Python REPL | python |
| Exit REPL | exit() |
| Create virtual environment | python -m venv .venv |
| Activate on Windows | .venv\Scripts\activate |
| Activate on macOS/Linux | source .venv/bin/activate |
| Deactivate | deactivate |
If Python is installed but:
doesn't work, check your Python installation and PATH configuration.
Remember:
Installing packages globally for every project can create dependency conflicts.
For larger projects, prefer a virtual environment.
.venvIf you created a virtual environment but don't activate it, your terminal may continue using the system Python environment.
Check whether:
appears in your terminal.
Your instructor might show:
while your computer shows:
That does not automatically mean something is wrong.
Different patch versions can exist.
Let's review what we learned.
PATH helps your operating system find programs such as Python when you type their commands in the terminal.
Use:
to check your Python version.
pip is commonly used to install and manage Python packages.
PyPI is the Python Package Index, where many Python packages are published.
REPL is an interactive Python environment where you can test Python instructions immediately.
Start it with:
A virtual environment provides a separate workspace for a project's Python packages.
Create one with:
If you remember only five things from this lesson, remember these:
.venv?deactivate command returns your terminal to the normal Python environment.Now complete these steps yourself.
Check your Python version:
Check pip:
Start the Python REPL:
Then calculate:
Expected result:
Create a virtual environment:
Activate it.
Windows:
macOS/Linux:
Check whether (.venv) appears in your terminal.
Deactivate it:
🎉 If you completed all seven tasks, your Python environment is ready for the next stage of the course.
In the next lesson, we will continue your Python learning journey with Syntax & Code Structure (1: Introduction and Setup).
Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
| Previous Lesson | Next Lesson |
|---|---|
| VS Code Setup | Syntax & Code Structure |
Test your understanding of this lesson with 8 questions. Each question has one correct answer.