Setup — Python, pip, venv, IDE

সেটআপ — Python, pip, venv, IDE — পেশাদার পরিবেশ তৈরি

Read: ~25 min Beginner 5 practice problems Live code runner

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.

প্রতিটি পেশাদার Python developer প্রতিদিন কয়েকটি tool ব্যবহার করেন: Python 3, pip, venv এবং VS Code-এর মতো একটি editor। প্রথমবার সঠিকভাবে setup করলে ভবিষ্যতে শত শত ঘণ্টা বাঁচবে।

2. Installing Python 3

OSRecommended wayVerify
Windows 10/11Download the official installer from python.org/downloads. During install, tick "Add Python to PATH".python --version
macOSbrew install python (Homebrew) or official installer from python.org.python3 --version
Ubuntu/Debiansudo apt update && sudo apt install python3 python3-pip python3-venvpython3 --version
Fedorasudo dnf install python3 python3-pippython3 --version
Warning On Windows, if you forget to tick "Add Python to PATH", 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:

terminal.sh
# 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।
repl_demo.py
# 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.

pip.sh
# 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 হলো Python-এর package installer। PyPI থেকে ৫ লক্ষের বেশি package pip দিয়ে install করা যায়। নতুন প্রজেক্টে কাজ শুরু করার আগে সাধারণত 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.

গ্লোবালভাবে package install করলে বিভিন্ন প্রজেক্টে version conflict হতে পারে। সমাধান হলো virtual environment (venv) — প্রতিটি প্রজেক্টের নিজস্ব বিচ্ছিন্ন Python পরিবেশ।
System Python Python 3.12 Minimal, don't touch /usr/bin/python3 Project A — venv Python 3.12 (linked) numpy 1.24, flask 3.0 ./project-a/.venv/ Project B — venv Python 3.12 (linked) numpy 2.0, django 5.0 ./project-b/.venv/ Figure 3.1 — একেকটি project-এর নিজস্ব venv, সিস্টেম Python অপরিবর্তিত থাকে।
venv.sh
# 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
Golden rule One venv per project. Always. Never install libraries globally unless they are system-level tools like 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.

VS Code বিনামূল্যে, দ্রুত, এবং PyCharm-এর মতো সশুল্ক IDE ছাড়া এটিই সেরা Python এডিটর। code.visualstudio.com থেকে নামিয়ে install করে Microsoft-এর অফিসিয়াল Python extension যোগ করুন। এটি আপনার venv স্বয়ংক্রিয়ভাবে detect করে।
FeatureShortcut / Tip
Open terminalCtrl+` (backtick)
Run current fileGreen ▶ in the top-right
Format on saveInstall Black Formatter extension, enable editor.formatOnSave
LintingInstall Pylint or Ruff extension
Select Python interpreterCtrl+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.

hello.py
# 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 (শব্দভাণ্ডার)

TermMeaningবাংলায়
REPLRead-Eval-Print-Loop — the interactive Python shell.interactive Python shell।
pipPython's package installer from PyPI.PyPI থেকে package install করার tool।
PyPIPython Package Index — pypi.org.Python-এর package ভাণ্ডার।
venvIsolated project-level Python environment.project-ভিত্তিক বিচ্ছিন্ন Python পরিবেশ।
requirements.txtList of exact package versions for reproducibility.প্রজেক্টের জন্য package version-এর তালিকা।
IDEIntegrated Development Environment — editor + debugger + tools.editor, debugger, tool — সব এক জায়গায়।

9. Practice Problems

  1. Write a one-line shell command to create a venv called .venv in the current folder.
    বর্তমান ফোল্ডারে .venv নামের একটি virtual environment তৈরির shell command লিখুন।
    ✨ Show Answer (উত্তর দেখুন)

    python -m venv .venv

    Windows-এ python, Mac/Linux-এ অনেক সময় python3 ব্যবহার করতে হয়।

  2. Write a Python script that prints the Python version and the current working directory.
    Python version এবং বর্তমান working directory প্রিন্ট করার script লিখুন।
    ✨ Show Answer (উত্তর দেখুন)
    info.py
    import sys, os
    
    print("Python version:", sys.version)
    print("Working directory:", os.getcwd())
  3. 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 অন্যটিকে ভাঙে না।

  4. Write a Python script that imports the math module and prints the value of π to 10 decimal places.
    math module import করে π-এর মান ১০ দশমিক স্থান পর্যন্ত প্রিন্ট করুন।
    ✨ Show Answer (উত্তর দেখুন)
    pi.py
    import math
    
    print(f"Pi to 10 places: {math.pi:.10f}")
  5. What does pip freeze > requirements.txt do, and why is it useful?
    pip freeze > requirements.txt কী করে ও কেন দরকার?
    ✨ Show Answer (উত্তর দেখুন)

    Answer: pip freeze lists every installed package with its exact version. Redirecting to requirements.txt writes that list to a file. A teammate (or a server, or your future self) can then recreate the same environment exactly with pip 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.

Python 3 install করে PATH-এ যোগ করুন। pip দিয়ে package, প্রতিটি project-এ আলাদা venv, version লিখে রাখুন requirements.txt-এ, এবং VS Code-এ লিখুন — এই চারটি অভ্যাস পুরো কোর্সে কাজে লাগবে।

Next Module → Your First Python Program — print, মন্তব্য, এবং Zen of Python।