[{"data":1,"prerenderedAt":300},["ShallowReactive",2],{"tag-labels":3,"site-header":4,"article-python-venv-pip-en":72},{},{"featuredPost":5,"navigations":29},{"id":6,"title":7,"title_id":8,"slug":9,"excerpt":10,"excerpt_id":11,"has_translation":12,"published_at":13,"reading_time":14,"hidden_from_listing":15,"tags":16,"thumbnail_image":21,"og_image":22,"series":23,"authors":28},110,"When You Pick a Framework Just to Look Different","Ketika Pilih Framework Cuma Biar Kelihatan Beda","ketika-pilih-framework-cuma-biar-kelihatan-beda","The last time you chose a new framework or library, was it because your problem needed that tool, or because it sounded cool and few people around you were using it? That question is uncomfortable. Technology decisions are often made for reasons that never appear in any technical document.","Terakhir kali kamu milih framework atau library baru, itu karena masalahmu butuh alat itu, atau karena alatnya kedengaran keren dan belum banyak yang pakai? Pertanyaan ini nggak enak dijawab. Soalnya keputusan teknologi sering diambil dengan alasan yang nggak pernah ditulis di dokumen teknis mana pun.",true,"2026-10-06T15:25:21.000Z",5,false,[17,18,19,20],"karier","framework","opini","pengalaman",null,"\u002Fog\u002Fketika-pilih-framework-cuma-biar-kelihatan-beda.png",{"id":24,"title":25,"title_id":26,"slug":27},9,"Articles","Artikel","all",[],[30,46,67],{"collection":31,"item":32},"series",{"__typename":31,"title":25,"title_id":26,"slug":27,"children_series":33},[34,38,42],{"title":35,"title_id":36,"slug":37},"Artificial Intelligence","Kecerdasan Artifisial","kecerdasan-artifisial",{"title":39,"title_id":40,"slug":41},"Programming Fundamentals","Konsep Dasar Pemrograman","konsep-dasar-pemrograman",{"title":43,"title_id":44,"slug":45},"Algorithms and Data Structures","Algoritma dan Struktur Data","algoritma-struktur-data",{"collection":31,"item":47},{"__typename":31,"title":48,"title_id":48,"slug":49,"children_series":50},"Tutorial","tutorial",[51,55,59,63],{"title":52,"title_id":53,"slug":54},"Learning Python","Belajar Python","belajar-python",{"title":56,"title_id":57,"slug":58},"Learning Go","Belajar Golang","belajar-golang",{"title":60,"title_id":61,"slug":62},"Learning Java","Belajar Java","belajar-java",{"title":64,"title_id":65,"slug":66},"Learning Pascal","Belajar Pascal","belajar-pascal",{"collection":31,"item":68},{"__typename":31,"title":69,"title_id":69,"slug":70,"children_series":71},"Lab","lab",[],{"article":73,"renderedBody":191,"renderedTakeaway":192,"latestArticles":193,"toc":289},{"id":74,"title":75,"title_id":76,"slug":77,"excerpt":78,"excerpt_id":79,"has_translation":12,"published_at":80,"reading_time":14,"hidden_from_listing":15,"tags":81,"thumbnail_image":21,"og_image":85,"series":86,"authors":183,"seoTitle":21,"seoDescription":21,"body_locale":186,"available_locales":187,"body":189,"takeway":190,"prerequisite":21},138,"Python venv: the Install That Went Into the Wrong Python","venv Python: Instalasi yang Masuk ke Python yang Salah","python-venv-pip","`pip install` printed Successfully installed, and the next run raised ModuleNotFoundError on the same machine. Two interpreters, one install, and the variable your script checks is the one the interpreter never sets.","`pip install` mencetak Successfully installed, lalu jalan berikutnya melempar ModuleNotFoundError di mesin yang sama. Dua interpreter, satu instalasi, dan variabel yang skripmu periksa justru tidak pernah dipasang oleh interpreter.","2026-11-07T12:00:00.000Z",[82,83,84],"python","venv","pip","\u002Fog\u002Fpython-venv-pip.png",{"id":87,"title":88,"title_id":89,"slug":90,"description":91,"description_id":92,"articles":93,"children_series":152,"parent_series":153},18,"Working with Python Scripts","Menggunakan Script Python","python-pemrograman-dengan-script","Leave the interpreter and start writing real .py files, including how to take input and print output.","Keluar dari interpreter dan mulai nulis file .py sendiri, lengkap dengan cara mengambil input dan menampilkan output.",[94,115,131,147],{"id":95,"title":96,"title_id":97,"slug":98,"excerpt":99,"excerpt_id":100,"has_translation":12,"published_at":101,"reading_time":102,"hidden_from_listing":15,"tags":103,"thumbnail_image":21,"og_image":106,"series":107,"authors":108},90,"Writing and Running a Python Script","Menulis dan Menjalankan Script Python","menulis-dan-menjalankan-script-python","A Python script is a file holding Python code, and it usually carries the .py extension.","Script python merupakan file berisi kode dengan bahasa Python yang biasanya memiliki ekstensi .py","2021-03-21T14:49:24.000Z",4,[82,49,104,105],"tooling","cli","\u002Fog\u002Fmenulis-dan-menjalankan-script-python.png",{"id":87,"title":88,"title_id":89,"slug":90},[109],{"authors_id":110},{"id":111,"name":112,"slug":113,"role":114,"profile_picture":21},1,"Daffa Izzuddin","izzudd","Writer",{"id":116,"title":117,"title_id":118,"slug":119,"excerpt":120,"excerpt_id":121,"has_translation":12,"published_at":122,"reading_time":102,"hidden_from_listing":15,"tags":123,"thumbnail_image":21,"og_image":126,"series":127,"authors":128},91,"Input and Output Systems in Python 3","Sistem Input dan Output pada Python 3","sistem-input-dan-output-pada-python-3","A few functions, print() and input() among them, are the standard tools most I\u002FO work in Python is built on.","Beberapa fungsi seperti print() dan input(), merupakan fungsi standar yang banyak digunakan untuk melakukan I\u002FO.","2021-05-19T14:57:25.000Z",[82,124,125],"input-output","dasar","\u002Fog\u002Fsistem-input-dan-output-pada-python-3.png",{"id":87,"title":88,"title_id":89,"slug":90},[129],{"authors_id":130},{"id":111,"name":112,"slug":113,"role":114,"profile_picture":21},{"id":132,"title":133,"title_id":134,"slug":135,"excerpt":136,"excerpt_id":137,"has_translation":12,"published_at":138,"reading_time":139,"hidden_from_listing":15,"tags":140,"thumbnail_image":21,"og_image":142,"series":143,"authors":144},136,"Python Modules: the Import That Printed the Report","Modul Python: Import yang Mencetak Laporannya","python-modules","You pull one function out into its own file, import it, and the whole report runs again and eats your input. A module is a file, `import` runs it top to bottom, and one line decides which of the two jobs it is doing.","Kamu memindahkan satu fungsi ke file sendiri, meng-import-nya, dan seluruh laporan jalan lagi lalu memakan inputmu. Modul adalah file, `import` menjalankannya dari atas ke bawah, dan satu baris menentukan pekerjaan mana yang sedang dijalankan file itu.","2026-11-06T01:00:00.000Z",7,[82,141],"modules","\u002Fog\u002Fpython-modules.png",{"id":87,"title":88,"title_id":89,"slug":90},[145],{"authors_id":146},{"id":111,"name":112,"slug":113,"role":114,"profile_picture":21},{"id":74,"title":75,"title_id":76,"slug":77,"excerpt":78,"excerpt_id":79,"has_translation":12,"published_at":80,"reading_time":14,"hidden_from_listing":15,"tags":81,"thumbnail_image":21,"og_image":85,"series":148,"authors":149},{"id":87,"title":88,"title_id":89,"slug":90},[150],{"authors_id":151},{"id":111,"name":112,"slug":113,"role":114,"profile_picture":21},[],{"id":154,"title":52,"title_id":53,"slug":54,"parent_series":155,"children_series":156},10,{"id":111,"title":48,"title_id":48,"slug":49},[157,162,167,168,173,178],{"id":158,"title":159,"title_id":160,"slug":161,"cover_image":21},16,"Getting Started with Python","Berkenalan dengan Bahasa Python","python-intro",{"id":163,"title":164,"title_id":165,"slug":166,"cover_image":21},17,"Variables, Types, and Operations","Variabel, Tipe Data, dan Operasi","python-variabel-tipe-data",{"id":87,"title":88,"title_id":89,"slug":90,"cover_image":21},{"id":169,"title":170,"title_id":171,"slug":172,"cover_image":21},19,"Control Structures","Struktur Kontrol","python-struktur-kontrol",{"id":174,"title":175,"title_id":176,"slug":177,"cover_image":21},20,"Functional Programming with Python","Pemrograman Fungsional dengan Python","python-pemrograman-fungsional",{"id":179,"title":180,"title_id":181,"slug":182,"cover_image":21},30,"Collections and Strings","Koleksi dan String","python-collections",[184],{"authors_id":185},{"id":111,"name":112,"slug":113,"role":114,"profile_picture":21},"en",[186,188],"id","\nThe install printed \"Successfully installed\". The script imported fine in one terminal. Then the editor's Run button, or a new shell, raised `ModuleNotFoundError` for the package you just installed, on the same machine and in the same project.\n\nYou have two interpreters on one machine, the system one and your project's venv, and `pip install` only touches the one that ran it.\n\nHere is the measured version, on Linux with Python 3.14.9 on 2026-11-07. The `venv` module ships with Python, so there is nothing to install first ([venv docs](https:\u002F\u002Fdocs.python.org\u002F3\u002Flibrary\u002Fvenv.html)).\n\n`python3 -m venv .venv` writes the venv into `.venv\u002F`. Activating it is a shell change: `source .venv\u002Fbin\u002Factivate` on macOS and Linux, `.venv\\Scripts\\activate` on Windows. After that, `python` and `pip` mean the venv. Activation is convenient, not required, because `.venv\u002Fbin\u002Fpython` is the same interpreter without it.\n\n```bash\n$ python3 --version\nPython 3.14.9\n$ python3 -m venv .venv\n$ .venv\u002Fbin\u002Fpip install requests\n```\n\nThe last line of the install output:\n\n```text\nSuccessfully installed certifi-2026.10.23 charset_normalizer-3.5.2 idna-3.20 requests-2.34.2 urllib3-2.8.0\n```\n\nOne `pip install requests` pulled five packages, and `du -sh .venv` reported `9.3M`. Now run the same one-line probe with each interpreter, on the same machine in the same second:\n\n```console\n$ .venv\u002Fbin\u002Fpython -c \"import requests; print(requests.__version__)\"\n2.34.2\n$ python3 -c \"import requests; print(requests.__version__)\"\nModuleNotFoundError: No module named 'requests'\n```\n\nThe first exits 0. The second exits 1. Nothing is wrong with the install. You asked a different Python.\n\nThe bug you will actually hit comes next. To find out which Python is running, many scripts read the shell variable `VIRTUAL_ENV`, which only exists while the venv is activated. Here is what that does.\n\n## Two files, one command\n\nSave this as `where.py`. It decides by reading the environment, and it exits 0 only when it believes it is in a venv.\n\n```python\n# where.py\nimport os\nimport sys\n\n\ndef which_interpreter():\n    if os.environ.get(\"VIRTUAL_ENV\"):\n        return \"venv\"\n    return \"system\"\n\n\ndef main():\n    kind = which_interpreter()\n    print(kind)\n    return 0 if kind == \"venv\" else 1\n\n\nraise SystemExit(main())\n```\n\nSave this next to it as `check_where.py`. It builds a throwaway venv, runs `where.py` with the venv's python and with the system one, and counts passes.\n\n```python\n# check_where.py\nimport os\nimport subprocess\nimport sys\nimport tempfile\n\npassed = 0\ntotal = 0\n\n\ndef check(name, ok, detail=\"\"):\n    global passed, total\n    total += 1\n    if ok:\n        passed += 1\n        print(f\"PASS  {name}\")\n    else:\n        print(f\"FAIL  {name}  \u003C- {detail}\")\n\n\nroot = os.path.dirname(os.path.abspath(__file__))\nscript = os.path.join(root, \"where.py\")\n\nhome = tempfile.mkdtemp(prefix=\"venvcheck-\")\nvenv_dir = os.path.join(home, \".venv\")\nsubprocess.run([sys.executable, \"-m\", \"venv\", venv_dir], check=True)\nbindir = \"Scripts\" if os.name == \"nt\" else \"bin\"\nvenv_python = os.path.join(venv_dir, bindir, \"python\" + (\".exe\" if os.name == \"nt\" else \"\"))\n\ninside = subprocess.run([venv_python, script], capture_output=True, text=True)\noutside = subprocess.run([sys.executable, script], capture_output=True, text=True)\n\ncheck(\"where.py runs when a venv calls it\", inside.returncode == 0, f\"exit {inside.returncode}\")\ncheck(\"a venv interpreter reports venv\", inside.stdout.strip() == \"venv\", repr(inside.stdout.strip()))\ncheck(\n    \"the system interpreter reports system\",\n    outside.returncode == 1 and outside.stdout.strip() == \"system\",\n    f\"exit {outside.returncode}, said {outside.stdout.strip()!r}\",\n)\n\nprint()\nprint(f\"{passed} of {total} checks passed\")\nraise SystemExit(0 if passed == total else 1)\n```\n\nRun `python3 check_where.py`. It exits 1:\n\n```text\nFAIL  where.py runs when a venv calls it  \u003C- exit 1\nFAIL  a venv interpreter reports venv  \u003C- 'system'\nPASS  the system interpreter reports system\n\n1 of 3 checks passed\n```\n\nThe venv's own python ran the script, and it still said `system`. `source .venv\u002Fbin\u002Factivate` changes your shell so that `python` means the venv. Calling `.venv\u002Fbin\u002Fpython` directly never touches that shell variable, so `VIRTUAL_ENV` is empty. The script asked the shell, and the shell was never told.\n\nAsk the interpreter instead. Inside a venv, `sys.prefix` points at the venv and `sys.base_prefix` points at the Python it was built from. Replace `where.py` with:\n\n```python\n# where.py\nimport sys\n\n\ndef inside_venv():\n    return sys.prefix != sys.base_prefix\n\n\ndef main():\n    kind = \"venv\" if inside_venv() else \"system\"\n    print(kind)\n    return 0 if kind == \"venv\" else 1\n\n\nraise SystemExit(main())\n```\n\nRun `python3 check_where.py` again. It exits 0:\n\n```text\nPASS  where.py runs when a venv calls it\nPASS  a venv interpreter reports venv\nPASS  the system interpreter reports system\n\n3 of 3 checks passed\n```\n\n## What this does not do\n\nThe checker tests which interpreter is running. It does not test whether your dependencies are the right ones, and it does not lock versions. It also cannot see the interpreter your editor is configured with, so the Run button still needs its own check.\n\nI only ran this on Linux. The Windows branch in the checker (`Scripts`, `python.exe`) is there for you to try, and I did not verify it.\n\nOne more trap: `pip freeze` in a brand-new venv prints nothing. An empty requirements file is not proof of a broken install. After the `requests` install above, [`pip freeze`](https:\u002F\u002Fpip.pypa.io\u002Fen\u002Fstable\u002Fcli\u002Fpip_freeze\u002F) printed exactly this:\n\n```text\ncertifi==2026.10.23\ncharset-normalizer==3.5.2\nidna==3.20\nrequests==2.34.2\nurllib3==2.8.0\n```\n\n## Run the checker from inside the venv\n\nNow run the same checker with the venv's own interpreter: `.venv\u002Fbin\u002Fpython check_where.py`. One check fails, and the exit code is 1:\n\n```text\nPASS  where.py runs when a venv calls it\nPASS  a venv interpreter reports venv\nFAIL  the system interpreter reports system  \u003C- exit 0, said 'venv'\n\n2 of 3 checks passed\n```\n\nThe checker compares against `sys.executable`. In this run that is the venv python, so \"the system interpreter\" was never tested.\n\nBefore you debug the next import error, print `sys.executable` from the script that failed. Which Python is it, and is that the one you installed into?\n\n","- `pip install` only ever touches the interpreter that ran it, so a project with a venv has two Pythons and the package landed in one of them.\n- `VIRTUAL_ENV` is set by activation, not by the interpreter, so `.venv\u002Fbin\u002Fpython where.py` still reports `system`.\n- `sys.prefix != sys.base_prefix` is the question to ask the interpreter itself, because it is true exactly when a venv started it.\n- The checker tests which interpreter is running, not whether your dependency versions are the right ones, and it cannot see the interpreter your editor runs.","\u003Cp>The install printed &quot;Successfully installed&quot;. The script imported fine in one terminal. Then the editor&#39;s Run button, or a new shell, raised \u003Ccode>ModuleNotFoundError\u003C\u002Fcode> for the package you just installed, on the same machine and in the same project.\u003C\u002Fp>\n\u003Cp>You have two interpreters on one machine, the system one and your project&#39;s venv, and \u003Ccode>pip install\u003C\u002Fcode> only touches the one that ran it.\u003C\u002Fp>\n\u003Cp>Here is the measured version, on Linux with Python 3.14.9 on 2026-11-07. The \u003Ccode>venv\u003C\u002Fcode> module ships with Python, so there is nothing to install first (\u003Ca href=\"https:\u002F\u002Fdocs.python.org\u002F3\u002Flibrary\u002Fvenv.html\">venv docs\u003C\u002Fa>).\u003C\u002Fp>\n\u003Cp>\u003Ccode>python3 -m venv .venv\u003C\u002Fcode> writes the venv into \u003Ccode>.venv\u002F\u003C\u002Fcode>. Activating it is a shell change: \u003Ccode>source .venv\u002Fbin\u002Factivate\u003C\u002Fcode> on macOS and Linux, \u003Ccode>.venv\\Scripts\\activate\u003C\u002Fcode> on Windows. After that, \u003Ccode>python\u003C\u002Fcode> and \u003Ccode>pip\u003C\u002Fcode> mean the venv. Activation is convenient, not required, because \u003Ccode>.venv\u002Fbin\u002Fpython\u003C\u002Fcode> is the same interpreter without it.\u003C\u002Fp>\n\n\u003Cdiv class=\"code-block-wrapper my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden bg-[#24292e] text-[#e1e4e8] transition-all\">\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ff5f56] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ffbd2e] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#27c93f] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"ml-2 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">BASH\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"%24%20python3%20--version%0APython%203.14.9%0A%24%20python3%20-m%20venv%20.venv%0A%24%20.venv%2Fbin%2Fpip%20install%20requests\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed bg-[#24292e]\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">$\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\"> python3\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> --version\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">Python\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> 3.14.9\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">$\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\"> python3\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> -m\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\"> venv\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\"> .venv\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">$\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\"> .venv\u002Fbin\u002Fpip\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\"> install\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\"> requests\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>The last line of the install output:\u003C\u002Fp>\n\n\u003Cdiv class=\"code-block-wrapper my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden bg-[#24292e] text-[#e1e4e8] transition-all\">\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ff5f56] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ffbd2e] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#27c93f] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"ml-2 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">TEXT\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"Successfully%20installed%20certifi-2026.10.23%20charset_normalizer-3.5.2%20idna-3.20%20requests-2.34.2%20urllib3-2.8.0\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed bg-[#24292e]\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\">\u003Ccode>Successfully installed certifi-2026.10.23 charset_normalizer-3.5.2 idna-3.20 requests-2.34.2 urllib3-2.8.0\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>One \u003Ccode>pip install requests\u003C\u002Fcode> pulled five packages, and \u003Ccode>du -sh .venv\u003C\u002Fcode> reported \u003Ccode>9.3M\u003C\u002Fcode>. Now run the same one-line probe with each interpreter, on the same machine in the same second:\u003C\u002Fp>\n\n\u003Cdiv class=\"code-block-wrapper my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden bg-[#24292e] text-[#e1e4e8] transition-all\">\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ff5f56] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ffbd2e] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#27c93f] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"ml-2 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">CONSOLE\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"%24%20.venv%2Fbin%2Fpython%20-c%20%22import%20requests%3B%20print(requests.__version__)%22%0A2.34.2%0A%24%20python3%20-c%20%22import%20requests%3B%20print(requests.__version__)%22%0AModuleNotFoundError%3A%20No%20module%20named%20'requests'\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed bg-[#24292e]\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">$\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\"> .venv\u002Fbin\u002Fpython\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> -c\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\"> \"import requests; print(requests.__version__)\"\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">2.34.2\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">$\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\"> python3\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> -c\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\"> \"import requests; print(requests.__version__)\"\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">ModuleNotFoundError:\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\"> No\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\"> module\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\"> named\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\"> 'requests'\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>The first exits 0. The second exits 1. Nothing is wrong with the install. You asked a different Python.\u003C\u002Fp>\n\u003Cp>The bug you will actually hit comes next. To find out which Python is running, many scripts read the shell variable \u003Ccode>VIRTUAL_ENV\u003C\u002Fcode>, which only exists while the venv is activated. Here is what that does.\u003C\u002Fp>\n\u003Ch2 id=\"two-files-one-command\">Two files, one command\u003C\u002Fh2>\n\u003Cp>Save this as \u003Ccode>where.py\u003C\u002Fcode>. It decides by reading the environment, and it exits 0 only when it believes it is in a venv.\u003C\u002Fp>\n\n\u003Cdiv class=\"code-block-wrapper my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden bg-[#24292e] text-[#e1e4e8] transition-all\">\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ff5f56] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ffbd2e] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#27c93f] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"ml-2 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">PYTHON\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"%23%20where.py%0Aimport%20os%0Aimport%20sys%0A%0A%0Adef%20which_interpreter()%3A%0A%20%20%20%20if%20os.environ.get(%22VIRTUAL_ENV%22)%3A%0A%20%20%20%20%20%20%20%20return%20%22venv%22%0A%20%20%20%20return%20%22system%22%0A%0A%0Adef%20main()%3A%0A%20%20%20%20kind%20%3D%20which_interpreter()%0A%20%20%20%20print(kind)%0A%20%20%20%20return%200%20if%20kind%20%3D%3D%20%22venv%22%20else%201%0A%0A%0Araise%20SystemExit(main())\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed bg-[#24292e]\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"color:#6A737D\"># where.py\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">import\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> os\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">import\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> sys\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">def\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> which_interpreter\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">():\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">    if\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> os.environ.get(\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"VIRTUAL_ENV\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">):\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">        return\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\"> \"venv\"\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">    return\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\"> \"system\"\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">def\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> main\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">():\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">    kind \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> which_interpreter()\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#79B8FF\">    print\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(kind)\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">    return\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> 0\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> if\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> kind \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">==\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\"> \"venv\"\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> else\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> 1\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">raise\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> SystemExit\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(main())\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>Save this next to it as \u003Ccode>check_where.py\u003C\u002Fcode>. It builds a throwaway venv, runs \u003Ccode>where.py\u003C\u002Fcode> with the venv&#39;s python and with the system one, and counts passes.\u003C\u002Fp>\n\n\u003Cdiv class=\"code-block-wrapper my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden bg-[#24292e] text-[#e1e4e8] transition-all\">\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ff5f56] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ffbd2e] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#27c93f] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"ml-2 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">PYTHON\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"%23%20check_where.py%0Aimport%20os%0Aimport%20subprocess%0Aimport%20sys%0Aimport%20tempfile%0A%0Apassed%20%3D%200%0Atotal%20%3D%200%0A%0A%0Adef%20check(name%2C%20ok%2C%20detail%3D%22%22)%3A%0A%20%20%20%20global%20passed%2C%20total%0A%20%20%20%20total%20%2B%3D%201%0A%20%20%20%20if%20ok%3A%0A%20%20%20%20%20%20%20%20passed%20%2B%3D%201%0A%20%20%20%20%20%20%20%20print(f%22PASS%20%20%7Bname%7D%22)%0A%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20print(f%22FAIL%20%20%7Bname%7D%20%20%3C-%20%7Bdetail%7D%22)%0A%0A%0Aroot%20%3D%20os.path.dirname(os.path.abspath(__file__))%0Ascript%20%3D%20os.path.join(root%2C%20%22where.py%22)%0A%0Ahome%20%3D%20tempfile.mkdtemp(prefix%3D%22venvcheck-%22)%0Avenv_dir%20%3D%20os.path.join(home%2C%20%22.venv%22)%0Asubprocess.run(%5Bsys.executable%2C%20%22-m%22%2C%20%22venv%22%2C%20venv_dir%5D%2C%20check%3DTrue)%0Abindir%20%3D%20%22Scripts%22%20if%20os.name%20%3D%3D%20%22nt%22%20else%20%22bin%22%0Avenv_python%20%3D%20os.path.join(venv_dir%2C%20bindir%2C%20%22python%22%20%2B%20(%22.exe%22%20if%20os.name%20%3D%3D%20%22nt%22%20else%20%22%22))%0A%0Ainside%20%3D%20subprocess.run(%5Bvenv_python%2C%20script%5D%2C%20capture_output%3DTrue%2C%20text%3DTrue)%0Aoutside%20%3D%20subprocess.run(%5Bsys.executable%2C%20script%5D%2C%20capture_output%3DTrue%2C%20text%3DTrue)%0A%0Acheck(%22where.py%20runs%20when%20a%20venv%20calls%20it%22%2C%20inside.returncode%20%3D%3D%200%2C%20f%22exit%20%7Binside.returncode%7D%22)%0Acheck(%22a%20venv%20interpreter%20reports%20venv%22%2C%20inside.stdout.strip()%20%3D%3D%20%22venv%22%2C%20repr(inside.stdout.strip()))%0Acheck(%0A%20%20%20%20%22the%20system%20interpreter%20reports%20system%22%2C%0A%20%20%20%20outside.returncode%20%3D%3D%201%20and%20outside.stdout.strip()%20%3D%3D%20%22system%22%2C%0A%20%20%20%20f%22exit%20%7Boutside.returncode%7D%2C%20said%20%7Boutside.stdout.strip()!r%7D%22%2C%0A)%0A%0Aprint()%0Aprint(f%22%7Bpassed%7D%20of%20%7Btotal%7D%20checks%20passed%22)%0Araise%20SystemExit(0%20if%20passed%20%3D%3D%20total%20else%201)\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed bg-[#24292e]\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"color:#6A737D\"># check_where.py\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">import\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> os\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">import\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> subprocess\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">import\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> sys\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">import\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> tempfile\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">passed \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> 0\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">total \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> 0\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">def\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> check\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(name, ok, detail\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">):\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">    global\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> passed, total\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">    total \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">+=\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> 1\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">    if\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> ok:\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        passed \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">+=\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> 1\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#79B8FF\">        print\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">f\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"PASS  \u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">{\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">name\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">}\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">)\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">    else\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">:\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#79B8FF\">        print\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">f\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"FAIL  \u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">{\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">name\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">}\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">  &#x3C;- \u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">{\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">detail\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">}\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">)\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">root \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> os.path.dirname(os.path.abspath(\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">__file__\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">))\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">script \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> os.path.join(root, \u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"where.py\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">)\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">home \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> tempfile.mkdtemp(\u003C\u002Fspan>\u003Cspan style=\"color:#FFAB70\">prefix\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"venvcheck-\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">)\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">venv_dir \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> os.path.join(home, \u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\".venv\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">)\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">subprocess.run([sys.executable, \u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"-m\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"venv\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">, venv_dir], \u003C\u002Fspan>\u003Cspan style=\"color:#FFAB70\">check\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">True\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">)\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">bindir \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\"> \"Scripts\"\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> if\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> os.name \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">==\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\"> \"nt\"\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> else\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\"> \"bin\"\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">venv_python \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> os.path.join(venv_dir, bindir, \u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"python\"\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> +\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> (\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\".exe\"\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> if\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> os.name \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">==\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\"> \"nt\"\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> else\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\"> \"\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">))\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">inside \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> subprocess.run([venv_python, script], \u003C\u002Fspan>\u003Cspan style=\"color:#FFAB70\">capture_output\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">True\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"color:#FFAB70\">text\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">True\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">)\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">outside \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> subprocess.run([sys.executable, script], \u003C\u002Fspan>\u003Cspan style=\"color:#FFAB70\">capture_output\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">True\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"color:#FFAB70\">text\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">True\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">)\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">check(\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"where.py runs when a venv calls it\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">, inside.returncode \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">==\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> 0\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">f\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"exit \u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">{\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">inside.returncode\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">}\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">)\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">check(\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"a venv interpreter reports venv\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">, inside.stdout.strip() \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">==\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\"> \"venv\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">repr\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(inside.stdout.strip()))\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">check(\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#9ECBFF\">    \"the system interpreter reports system\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">,\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">    outside.returncode \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">==\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> 1\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> and\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> outside.stdout.strip() \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">==\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\"> \"system\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">,\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">    f\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"exit \u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">{\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">outside.returncode\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">}\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">, said \u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">{\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">outside.stdout.strip()\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">!r\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">}\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">,\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">)\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#79B8FF\">print\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">()\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#79B8FF\">print\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">f\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">{\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">passed\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">}\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\"> of \u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">{\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">total\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">}\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\"> checks passed\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">)\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">raise\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> SystemExit\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">0\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> if\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> passed \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">==\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> total \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">else\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> 1\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">)\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>Run \u003Ccode>python3 check_where.py\u003C\u002Fcode>. It exits 1:\u003C\u002Fp>\n\n\u003Cdiv class=\"code-block-wrapper my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden bg-[#24292e] text-[#e1e4e8] transition-all\">\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ff5f56] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ffbd2e] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#27c93f] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"ml-2 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">TEXT\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"FAIL%20%20where.py%20runs%20when%20a%20venv%20calls%20it%20%20%3C-%20exit%201%0AFAIL%20%20a%20venv%20interpreter%20reports%20venv%20%20%3C-%20'system'%0APASS%20%20the%20system%20interpreter%20reports%20system%0A%0A1%20of%203%20checks%20passed\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed bg-[#24292e]\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\">\u003Ccode>FAIL  where.py runs when a venv calls it  &lt;- exit 1\nFAIL  a venv interpreter reports venv  &lt;- 'system'\nPASS  the system interpreter reports system\n\n1 of 3 checks passed\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>The venv&#39;s own python ran the script, and it still said \u003Ccode>system\u003C\u002Fcode>. \u003Ccode>source .venv\u002Fbin\u002Factivate\u003C\u002Fcode> changes your shell so that \u003Ccode>python\u003C\u002Fcode> means the venv. Calling \u003Ccode>.venv\u002Fbin\u002Fpython\u003C\u002Fcode> directly never touches that shell variable, so \u003Ccode>VIRTUAL_ENV\u003C\u002Fcode> is empty. The script asked the shell, and the shell was never told.\u003C\u002Fp>\n\u003Cp>Ask the interpreter instead. Inside a venv, \u003Ccode>sys.prefix\u003C\u002Fcode> points at the venv and \u003Ccode>sys.base_prefix\u003C\u002Fcode> points at the Python it was built from. Replace \u003Ccode>where.py\u003C\u002Fcode> with:\u003C\u002Fp>\n\n\u003Cdiv class=\"code-block-wrapper my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden bg-[#24292e] text-[#e1e4e8] transition-all\">\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ff5f56] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ffbd2e] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#27c93f] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"ml-2 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">PYTHON\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"%23%20where.py%0Aimport%20sys%0A%0A%0Adef%20inside_venv()%3A%0A%20%20%20%20return%20sys.prefix%20!%3D%20sys.base_prefix%0A%0A%0Adef%20main()%3A%0A%20%20%20%20kind%20%3D%20%22venv%22%20if%20inside_venv()%20else%20%22system%22%0A%20%20%20%20print(kind)%0A%20%20%20%20return%200%20if%20kind%20%3D%3D%20%22venv%22%20else%201%0A%0A%0Araise%20SystemExit(main())\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed bg-[#24292e]\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"color:#6A737D\"># where.py\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">import\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> sys\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">def\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> inside_venv\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">():\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">    return\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> sys.prefix \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">!=\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> sys.base_prefix\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">def\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> main\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">():\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">    kind \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\"> \"venv\"\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> if\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> inside_venv() \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">else\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\"> \"system\"\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#79B8FF\">    print\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(kind)\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">    return\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> 0\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> if\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> kind \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">==\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\"> \"venv\"\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> else\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> 1\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">raise\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> SystemExit\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(main())\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>Run \u003Ccode>python3 check_where.py\u003C\u002Fcode> again. It exits 0:\u003C\u002Fp>\n\n\u003Cdiv class=\"code-block-wrapper my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden bg-[#24292e] text-[#e1e4e8] transition-all\">\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ff5f56] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ffbd2e] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#27c93f] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"ml-2 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">TEXT\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"PASS%20%20where.py%20runs%20when%20a%20venv%20calls%20it%0APASS%20%20a%20venv%20interpreter%20reports%20venv%0APASS%20%20the%20system%20interpreter%20reports%20system%0A%0A3%20of%203%20checks%20passed\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed bg-[#24292e]\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\">\u003Ccode>PASS  where.py runs when a venv calls it\nPASS  a venv interpreter reports venv\nPASS  the system interpreter reports system\n\n3 of 3 checks passed\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Ch2 id=\"what-this-does-not-do\">What this does not do\u003C\u002Fh2>\n\u003Cp>The checker tests which interpreter is running. It does not test whether your dependencies are the right ones, and it does not lock versions. It also cannot see the interpreter your editor is configured with, so the Run button still needs its own check.\u003C\u002Fp>\n\u003Cp>I only ran this on Linux. The Windows branch in the checker (\u003Ccode>Scripts\u003C\u002Fcode>, \u003Ccode>python.exe\u003C\u002Fcode>) is there for you to try, and I did not verify it.\u003C\u002Fp>\n\u003Cp>One more trap: \u003Ccode>pip freeze\u003C\u002Fcode> in a brand-new venv prints nothing. An empty requirements file is not proof of a broken install. After the \u003Ccode>requests\u003C\u002Fcode> install above, \u003Ca href=\"https:\u002F\u002Fpip.pypa.io\u002Fen\u002Fstable\u002Fcli\u002Fpip_freeze\u002F\">\u003Ccode>pip freeze\u003C\u002Fcode>\u003C\u002Fa> printed exactly this:\u003C\u002Fp>\n\n\u003Cdiv class=\"code-block-wrapper my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden bg-[#24292e] text-[#e1e4e8] transition-all\">\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ff5f56] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ffbd2e] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#27c93f] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"ml-2 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">TEXT\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"certifi%3D%3D2026.10.23%0Acharset-normalizer%3D%3D3.5.2%0Aidna%3D%3D3.20%0Arequests%3D%3D2.34.2%0Aurllib3%3D%3D2.8.0\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed bg-[#24292e]\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\">\u003Ccode>certifi==2026.10.23\ncharset-normalizer==3.5.2\nidna==3.20\nrequests==2.34.2\nurllib3==2.8.0\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Ch2 id=\"run-the-checker-from-inside-the-venv\">Run the checker from inside the venv\u003C\u002Fh2>\n\u003Cp>Now run the same checker with the venv&#39;s own interpreter: \u003Ccode>.venv\u002Fbin\u002Fpython check_where.py\u003C\u002Fcode>. One check fails, and the exit code is 1:\u003C\u002Fp>\n\n\u003Cdiv class=\"code-block-wrapper my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden bg-[#24292e] text-[#e1e4e8] transition-all\">\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ff5f56] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ffbd2e] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#27c93f] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"ml-2 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">TEXT\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"PASS%20%20where.py%20runs%20when%20a%20venv%20calls%20it%0APASS%20%20a%20venv%20interpreter%20reports%20venv%0AFAIL%20%20the%20system%20interpreter%20reports%20system%20%20%3C-%20exit%200%2C%20said%20'venv'%0A%0A2%20of%203%20checks%20passed\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed bg-[#24292e]\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\">\u003Ccode>PASS  where.py runs when a venv calls it\nPASS  a venv interpreter reports venv\nFAIL  the system interpreter reports system  &lt;- exit 0, said 'venv'\n\n2 of 3 checks passed\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>The checker compares against \u003Ccode>sys.executable\u003C\u002Fcode>. In this run that is the venv python, so &quot;the system interpreter&quot; was never tested.\u003C\u002Fp>\n\u003Cp>Before you debug the next import error, print \u003Ccode>sys.executable\u003C\u002Fcode> from the script that failed. Which Python is it, and is that the one you installed into?\u003C\u002Fp>\n","\u003Cul>\n\u003Cli>\u003Ccode>pip install\u003C\u002Fcode> only ever touches the interpreter that ran it, so a project with a venv has two Pythons and the package landed in one of them.\u003C\u002Fli>\n\u003Cli>\u003Ccode>VIRTUAL_ENV\u003C\u002Fcode> is set by activation, not by the interpreter, so \u003Ccode>.venv\u002Fbin\u002Fpython where.py\u003C\u002Fcode> still reports \u003Ccode>system\u003C\u002Fcode>.\u003C\u002Fli>\n\u003Cli>\u003Ccode>sys.prefix != sys.base_prefix\u003C\u002Fcode> is the question to ask the interpreter itself, because it is true exactly when a venv started it.\u003C\u002Fli>\n\u003Cli>The checker tests which interpreter is running, not whether your dependency versions are the right ones, and it cannot see the interpreter your editor runs.\u003C\u002Fli>\n\u003C\u002Ful>\n",[194,216,235,252,257,272],{"id":195,"title":196,"title_id":197,"slug":198,"excerpt":199,"excerpt_id":200,"has_translation":12,"published_at":201,"reading_time":102,"hidden_from_listing":15,"tags":202,"thumbnail_image":21,"og_image":207,"series":208,"authors":213},48,"What a Linked List Actually Is","Tentang Struktur Data LinkedList","tentang-struktur-data-linked-list","A linked list is a linear chain of nodes, each holding data and a pointer to the next node. Here is what that chain looks like, what it costs next to an array, and the same minimal implementation in Java, Python, and JavaScript.","Linked list adalah rantai linear berisi node, dan setiap node menyimpan data plus pointer ke node berikutnya. Ini bentuk rantainya, ongkosnya dibanding array, dan implementasi paling sederhana dalam Java, Python, serta JavaScript.","2026-11-21T01:00:00.000Z",[203,204,205,206],"struktur-data","linked-list","pointer","konsep","\u002Fog\u002Ftentang-struktur-data-linked-list.png",{"id":209,"title":210,"title_id":211,"slug":212},28,"Linear Data Structures","Struktur Data Linear","asd-struktur-linear",[214],{"authors_id":215},{"id":111,"name":112,"slug":113,"role":114,"profile_picture":21},{"id":217,"title":218,"title_id":219,"slug":220,"excerpt":221,"excerpt_id":222,"has_translation":12,"published_at":223,"reading_time":139,"hidden_from_listing":15,"tags":224,"thumbnail_image":21,"og_image":226,"series":227,"authors":232},47,"Why Understanding Algorithms and Data Structures Actually Matters","Pentingnya Memahami Algoritma dan Struktur Data","pentingnya-memahami-algoritma-dan-struktur-data","An algorithm is an ordered list of steps, and that order decides how expensive a problem is. The examples are on the back of an instant noodle packet, in a factorial, and behind ctrl+z.","Sebagai konsep fundamental, algoritma menentukan seberapa mahal sebuah masalah diselesaikan. Contohnya ada di bungkus mie instan, di bilangan faktorial, dan di tombol undo.","2026-11-19T01:00:00.000Z",[225,203,206,125],"algoritma","\u002Fog\u002Fpentingnya-memahami-algoritma-dan-struktur-data.png",{"id":228,"title":229,"title_id":230,"slug":231},27,"About Algorithms and Data Structures","Tentang Algoritma dan Struktur Data","asd-intro",[233],{"authors_id":234},{"id":111,"name":112,"slug":113,"role":114,"profile_picture":21},{"id":236,"title":237,"title_id":238,"slug":239,"excerpt":240,"excerpt_id":241,"has_translation":12,"published_at":242,"reading_time":14,"hidden_from_listing":15,"tags":243,"thumbnail_image":21,"og_image":247,"series":248,"authors":249},108,"At 11 a.m. the AI Quota Runs Out, and the Work Stops There","Jam 11 siang kuota AI-nya habis, dan kerjaan berhenti di situ","jam-11-kuota-ai-habis-kerjaan-berhenti","The panel says the usage limit is reached and the work stops, not because it is finished. Three guesses explain it, and all three are wrong: the limit is shaped like a cliff, and the day is built on top of one tool.","Panel di layar bilang batas pemakaian tercapai, dan kerja berhenti di situ. Bukan karena selesai. Ada tiga tebakan kenapa ini terjadi, dan ketiganya salah: batasnya berbentuk tebing, dan harinya dibangun di atas satu alat.","2026-11-12T01:00:00.000Z",[244,104,245,246],"ai","rate-limit","produktivitas","\u002Fog\u002Fjam-11-kuota-ai-habis-kerjaan-berhenti.png",{"id":24,"title":25,"title_id":26,"slug":27},[250],{"authors_id":251},{"id":111,"name":112,"slug":113,"role":114,"profile_picture":21},{"id":74,"title":75,"title_id":76,"slug":77,"excerpt":78,"excerpt_id":79,"has_translation":12,"published_at":80,"reading_time":14,"hidden_from_listing":15,"tags":81,"thumbnail_image":21,"og_image":85,"series":253,"authors":254},{"id":87,"title":88,"title_id":89,"slug":90},[255],{"authors_id":256},{"id":111,"name":112,"slug":113,"role":114,"profile_picture":21},{"id":258,"title":259,"title_id":260,"slug":261,"excerpt":262,"excerpt_id":263,"has_translation":12,"published_at":264,"reading_time":14,"hidden_from_listing":15,"tags":265,"thumbnail_image":21,"og_image":267,"series":268,"authors":269},139,"Python Classes: the History Every Account Shared","Python Class: Riwayat yang Dipakai Bersama Semua Akun","python-class-object","Two accounts, and each history lists the other account's deposits. The list sat in the class body, `append` never writes to the object, so both accounts appended into the same one.","Dua akun, dan riwayat masing-masing memuat setoran akun lain. List-nya duduk di body class, `append` tidak pernah menulis ke objek, jadi kedua akun menambah ke list yang sama.","2026-11-07T01:00:00.000Z",[82,266],"oop","\u002Fog\u002Fpython-class-object.png",{"id":154,"title":52,"title_id":53,"slug":54},[270],{"authors_id":271},{"id":111,"name":112,"slug":113,"role":114,"profile_picture":21},{"id":273,"title":274,"title_id":275,"slug":276,"excerpt":277,"excerpt_id":278,"has_translation":12,"published_at":138,"reading_time":14,"hidden_from_listing":15,"tags":279,"thumbnail_image":21,"og_image":282,"series":283,"authors":286},137,"Java Operators: the Average That Came Out a Whole Number","Operator Java: Rata-Rata yang Keluar Sebagai Bilangan Bulat","java-operators","Three scores, one division, and the average prints as 82. Both operands are `int`, so the fraction is cut off, and the obvious cast prints `82.0` without fixing anything.","Tiga nilai, satu pembagian, dan rata-ratanya tercetak 82. Kedua operand-nya `int`, jadi pecahannya dipotong, dan cast yang paling wajar malah mencetak `82.0` tanpa memperbaiki apa pun.",[280,281],"java","operator","\u002Fog\u002Fjava-operators.png",{"id":284,"title":164,"title_id":165,"slug":285},22,"java-variabel-tipe-data",[287],{"authors_id":288},{"id":111,"name":112,"slug":113,"role":114,"profile_picture":21},[290,294,297],{"text":291,"depth":292,"id":293},"Two files, one command",2,"two-files-one-command",{"text":295,"depth":292,"id":296},"What this does not do","what-this-does-not-do",{"text":298,"depth":292,"id":299},"Run the checker from inside the venv","run-the-checker-from-inside-the-venv",1794054568027]