Setup — Python, pip, venv, IDE
সেটআপ — Python, pip, venv, IDE — পেশাদার পরিবেশ তৈরি
1. The Professional Python Workspace
Every serious Python developer uses a small handful of tools every day: Python 3 itself, a package manager (pip), a virtual environment (venv), and a code editor like VS Code. Setting these up correctly once will save you hundreds of hours of trouble later.
2. Installing Python 3
| OS | Recommended way | Verify |
|---|---|---|
| Windows 10/11 | Download the official installer from python.org/downloads. During install, tick "Add Python to PATH". | python --version |
| macOS | brew install python (Homebrew) or official installer from python.org. | python3 --version |
| Ubuntu/Debian | sudo apt update && sudo apt install python3 python3-pip python3-venv | python3 --version |
| Fedora | sudo dnf install python3 python3-pip | python3 --version |
python will not be found from the command line.
The fix is to run the installer again and choose Modify → Add Python to environment variables.
Windows-এ install করার সময় "Add Python to PATH" টিক না দিলে command line থেকে
python কাজ করবে না। Installer আবার চালিয়ে Modify করে ঠিক করে নিন।
Once installed, open a terminal (PowerShell on Windows, Terminal on Mac/Linux) and check:
# Check version — should be 3.10 or newer
python --version
# or, on most Mac/Linux systems:
python3 --version
# Start the interactive REPL
python
3. The REPL — Your First Friend
When you type python (or python3) alone, you land in the REPL —
Read-Eval-Print-Loop. You type a line, Python evaluates it, and prints the result. The REPL is the fastest way
to test a small idea.
python লিখে Enter দিলে আপনি REPL-এ ঢুকে যাবেন — Read-Eval-Print-Loop। একটি লাইন লিখলে Python সঙ্গে সঙ্গে মূল্যায়ন করে উত্তর দেখায়। ছোট একটি ধারণা যাচাইয়ের দ্রুততম উপায় REPL।
# These would be interactive REPL lines. Here they run as a script.
print(2 + 3)
print(10 ** 6) # 10 to the 6th
print(len("Bangladesh"))
print("Hello".upper())
4. pip — Python's Package Manager
pip is the tool that installs and manages third-party Python packages from PyPI
(the Python Package Index at pypi.org). Over 500,000 packages are published there today.
# Install a package
pip install requests
# Install a specific version
pip install "django==5.0"
# Upgrade a package
pip install --upgrade pip
# List what is installed
pip list
# Uninstall
pip uninstall requests
pip install --upgrade pip দিয়ে pip-কেই আপডেট করে নেওয়া ভালো।
5. venv — One Project, One Environment
Installing packages globally on your system is a recipe for conflicts. Project A needs numpy 1.24,
project B needs numpy 2.0 — they can't coexist globally. The solution is a virtual environment:
an isolated folder containing its own Python and its own packages.
# Create a venv named .venv inside your project folder
python -m venv .venv
# Activate it
# Windows PowerShell:
.venv\Scripts\Activate.ps1
# Mac / Linux:
source .venv/bin/activate
# Now pip installs are local to this project
pip install requests flask
# Save exact versions for teammates
pip freeze > requirements.txt
# A new teammate can recreate the environment
pip install -r requirements.txt
# Exit the venv when done
deactivate
pip
or virtualenv itself.
সোনালী নিয়ম: প্রতিটি project-এর জন্য আলাদা venv। গ্লোবালভাবে library install করবেন না।
6. VS Code — The Editor
Visual Studio Code is free, fast, and has the best Python support outside of a paid IDE like PyCharm.
Install it from code.visualstudio.com, then install the official Python extension from Microsoft.
VS Code will detect your venv automatically and give you IntelliSense, debugging, linting, and testing in one window.
code.visualstudio.com থেকে নামিয়ে install করে Microsoft-এর অফিসিয়াল Python extension যোগ করুন। এটি আপনার venv স্বয়ংক্রিয়ভাবে detect করে।
| Feature | Shortcut / Tip |
|---|---|
| Open terminal | Ctrl+` (backtick) |
| Run current file | Green ▶ in the top-right |
| Format on save | Install Black Formatter extension, enable editor.formatOnSave |
| Linting | Install Pylint or Ruff extension |
| Select Python interpreter | Ctrl+Shift+P → "Python: Select Interpreter" → pick your .venv |
7. Your First Script in VS Code
Create a file called hello.py and press the green ▶ button. You should see the output in the Terminal pane.
# Run this with: python hello.py
import sys
print("Hello from ABCL TECH!")
print(f"Running Python {sys.version_info.major}.{sys.version_info.minor}")
8. Vocabulary (শব্দভাণ্ডার)
| Term | Meaning | বাংলায় |
|---|---|---|
| REPL | Read-Eval-Print-Loop — the interactive Python shell. | interactive Python shell। |
| pip | Python's package installer from PyPI. | PyPI থেকে package install করার tool। |
| PyPI | Python Package Index — pypi.org. | Python-এর package ভাণ্ডার। |
| venv | Isolated project-level Python environment. | project-ভিত্তিক বিচ্ছিন্ন Python পরিবেশ। |
| requirements.txt | List of exact package versions for reproducibility. | প্রজেক্টের জন্য package version-এর তালিকা। |
| IDE | Integrated Development Environment — editor + debugger + tools. | editor, debugger, tool — সব এক জায়গায়। |
9. Practice Problems
-
Write a one-line shell command to create a venv called
.venvin the current folder.বর্তমান ফোল্ডারে.venvনামের একটি virtual environment তৈরির shell command লিখুন।✨ Show Answer (উত্তর দেখুন)
python -m venv .venvWindows-এ
python, Mac/Linux-এ অনেক সময়python3ব্যবহার করতে হয়। -
Write a Python script that prints the Python version and the current working directory.Python version এবং বর্তমান working directory প্রিন্ট করার script লিখুন।
✨ Show Answer (উত্তর দেখুন)
info.pyimport sys, os print("Python version:", sys.version) print("Working directory:", os.getcwd()) -
Explain in two or three sentences why you should use a venv instead of installing packages globally.কেন গ্লোবালভাবে install না করে venv ব্যবহার করা উচিত — ২–৩ বাক্যে ব্যাখ্যা করুন।
✨ Show Answer (উত্তর দেখুন)
Answer: Different projects often require different package versions (project A needs numpy 1.24, project B needs numpy 2.0). A global install forces a single version and causes conflicts. A venv gives each project its own isolated Python environment, so upgrading a package in one project cannot break another.
বিভিন্ন project-এ বিভিন্ন package version লাগে। global install-এ conflict হয়। venv প্রতিটি project-কে আলাদা পরিবেশ দেয় — একটির upgrade অন্যটিকে ভাঙে না।
-
Write a Python script that imports the
mathmodule and prints the value of π to 10 decimal places.math module import করে π-এর মান ১০ দশমিক স্থান পর্যন্ত প্রিন্ট করুন।✨ Show Answer (উত্তর দেখুন)
pi.pyimport math print(f"Pi to 10 places: {math.pi:.10f}") -
What does
pip freeze > requirements.txtdo, and why is it useful?pip freeze > requirements.txtকী করে ও কেন দরকার?✨ Show Answer (উত্তর দেখুন)
Answer:
pip freezelists every installed package with its exact version. Redirecting torequirements.txtwrites that list to a file. A teammate (or a server, or your future self) can then recreate the same environment exactly withpip install -r requirements.txt. It makes your project reproducible across machines.pip freezeবর্তমান package ও সঠিক version তালিকা করে। ফাইলে save করলে অন্য কেউpip install -r requirements.txtদিয়ে হুবহু একই পরিবেশ বানাতে পারে — reproducible project-এর মূল শর্ত।
Summary — Module 03
Install Python 3, add it to PATH, and verify with python --version. Use pip to install packages,
and always put each project in its own venv. Keep a requirements.txt for reproducibility, and use VS Code
with the official Python extension as your daily editor. These four habits — Python, pip, venv, VS Code — will carry you through the rest of this course.
requirements.txt-এ, এবং VS Code-এ লিখুন — এই চারটি অভ্যাস পুরো কোর্সে কাজে লাগবে।