Python Project အတွက် venv စတင်သုံးမယ် | Your First Virtual Environment
Project package တွေကို ခွဲထားရန် Python venv အခြေခံကို လေ့ကျင့်ပါ။ Start a project environment without installing extra packages.
21CT Admin5 min read10/23/2026
#Python#Programming#Virtual Environments
မြန်မာ — Project တစ်ခုအတွက် ကိုယ်ပိုင် environment
Python project တွေမှာ လိုအပ်တဲ့ package တွေ မတူနိုင်ပါတယ်။ venv က project တစ်ခုအတွက် သီးခြား Python package နေရာတစ်ခု ဖန်တီးပေးပါတယ်။ ဒါဟာ dependency ခွဲထားဖို့ဖြစ်ပြီး မယုံကြည်ရတဲ့ code ကို လုံခြုံအောင် run ပေးတဲ့ sandbox မဟုတ်ပါဘူး။
စမ်းရန် — Python ထည့်သွင်းပြီးသား Windows ကွန်ပျူတာကို သုံးပါ။ practice-python ဆိုတဲ့ folder အသစ်တစ်ခု ဖန်တီးပြီး အဲဒီနေရာမှာ terminal ဖွင့်ပါ။ python --version နဲ့ Python ရှိမရှိ စစ်ပါ။ Command မတွေ့ရင် installation ကို အရင်ပြင်ဆင်ပါ။
ပြီးရင် ဒီ command ကို run ပါ:
python -m venv .venv
Environment ထဲက Python ကို တိုက်ရိုက်သုံးပြီး pip အချက်အလက်ကို စစ်ပါ:
.\.venv\Scripts\python.exe -m pip --version
ဒီ check က package အသစ် မတင်ပါဘူး။ Output မှာ ကိုယ့် project ရဲ့ .venv အောက်က pip လမ်းကြောင်းကို ရှာကြည့်ပါ။ Activation မလုပ်ဘဲ interpreter ကို တိုက်ရိုက်ခေါ်ထားတာ ဖြစ်ပါတယ်။
လေ့ကျင့်ခန်း — Project folder ထဲမှာ notes.txt တစ်ခုလုပ်ပြီး ဒီနေ့သိခဲ့တာ နှစ်ကြောင်းရေးပါ။ ကိုယ်ရေးတဲ့ source နဲ့ notes တွေကို .venv အတွင်း မသိမ်းပါနဲ့။ အခြားစက်မှာ လိုအပ်ရင် environment ကို ပြန်ဖန်တီးပါ။ .venv ကို project source အဖြစ် Git ထဲ မတင်ပါနဲ့။ ပုံထဲက package နာမည်တွေက ဥပမာသာဖြစ်ပြီး ဒီလေ့ကျင့်ခန်းမှာ တင်ရန်မလိုပါဘူး။
English — One environment for a project
Different Python projects can need different packages. venv gives a project its own package environment. Dependency isolation is not a security sandbox for untrusted code.
Practice on Windows with Python already installed. Create a folder named practice-python and open a terminal there. Check python --version first; resolve a missing Python installation before continuing.
Create the environment:
python -m venv .venv
Check its pip directly:
.\.venv\Scripts\python.exe -m pip --version
This check installs no extra packages. Look for your project's .venv path in the output. Calling the interpreter directly avoids needing to activate the environment for this exercise.
Challenge: write two learning notes in a notes.txt file in the project folder. Keep your source and notes outside .venv. Recreate environments on another machine rather than copying them, and do not commit .venv to Git. Package names in the illustration are examples, not an installation list for this exercise.
Primary reference / မူရင်းရင်းမြစ်
Python documentation — venv:
https://docs.python.org/3/library/venv.html
Cover: original AI-generated educational illustration for 21CT.