{"id":57504,"date":"2026-09-30T20:47:50","date_gmt":"2026-09-30T20:47:50","guid":{"rendered":"https:\/\/www.askpython.com\/?p=57504"},"modified":"2026-09-30T20:47:51","modified_gmt":"2026-09-30T20:47:51","slug":"find-where-python-is-installed","status":"publish","type":"post","link":"https:\/\/www.askpython.com\/python\/examples\/find-where-python-is-installed","title":{"rendered":"Where Is Python Installed? Find Its Path"},"content":{"rendered":"<!-- article-type: how-to-use -->\n\n<p class=\"wp-block-paragraph\">An IDE can run Python even when `where.exe python` returns no match in a separate shell. I\u2019m intrigued that a blank lookup can coexist with a running interpreter.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can get the runtime path from the environment that launches your program. The first distinction is between a command your shell can find and the executable reported by the running process.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Which Python path are you trying to find?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A shell lookup answers which command your terminal can start. Inside a running Python process, <a href=\"https:\/\/docs.python.org\/3\/library\/sys.html\" target=\"_blank\" rel=\"noopener\">sys.executable<\/a> reports the executable path.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">An environment manager or integrated development environment (IDE) may choose a runtime separately from the shell, so check the environment that launches your program.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Homebrew documents its prefixes. Other installers can place Python in different directories.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The executable path names a file. An installation prefix is a directory, so the two values answer different questions.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Question<\/th><th>Check<\/th><th>What it tells you<\/th><\/tr><\/thead><tbody><tr><td>Which executable runs this Python process?<\/td><td>sys.executable<\/td><td>The interpreter path for the current process<\/td><\/tr><tr><td>Which command can this shell start?<\/td><td>Windows or Unix-like shell lookup<\/td><td>One or more shell-resolved candidates<\/td><\/tr><tr><td>Which environment is active?<\/td><td>sys.prefix and sys.base_prefix<\/td><td>The active environment prefix and base prefix<\/td><\/tr><tr><td>Where are Python libraries installed?<\/td><td>python3 -m site<\/td><td>The site directories used by that interpreter<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Start from the environment that runs your code<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Run the check from the same terminal or environment that starts your program. A separate terminal can resolve a different Python command.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open the terminal or IDE environment used to launch the program.<\/li>\n\n\n<li>If you use a virtual environment or Conda environment, activate or select it first.<\/li>\n\n\n<li>Use the command name your program uses, such as python on Windows or python3 in a macOS or Linux shell.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">An IDE may select its interpreter in project settings, so a check in its integrated console is more useful than a lookup in an unrelated shell.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The shell resolves names such as python and python3 through PATH. This environment variable tells the shell which directories to search, and activating an environment can change the result.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Print the executable Python is running<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Use the same Python command that runs your script. In Windows Command Prompt or PowerShell, use python.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\npython -c &quot;import sys; print(sys.executable)&quot;\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">In a macOS or Linux shell, use python3 to ask the running process for its executable path.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\npython3 -c &#039;import sys; print(sys.executable)&#039;\n<\/pre><\/div>\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1920\" height=\"296\" src=\"https:\/\/www.askpython.com\/wp-content\/uploads\/2026\/09\/python-executable-path.png\" alt=\"Terminal output showing sys.executable printing the path of the current Python process\" class=\"wp-image-71679\" srcset=\"https:\/\/www.askpython.com\/wp-content\/uploads\/2026\/09\/python-executable-path.png 1920w, https:\/\/www.askpython.com\/wp-content\/uploads\/2026\/09\/python-executable-path-300x46.png 300w, https:\/\/www.askpython.com\/wp-content\/uploads\/2026\/09\/python-executable-path-1024x158.png 1024w, https:\/\/www.askpython.com\/wp-content\/uploads\/2026\/09\/python-executable-path-768x118.png 768w, https:\/\/www.askpython.com\/wp-content\/uploads\/2026\/09\/python-executable-path-1536x237.png 1536w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><figcaption class=\"wp-element-caption\">sys.executable prints the executable selected for the Python process running this command.<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Use the printed path when a tool asks you to select the same Python runtime. Python&#8217;s sys documentation describes sys.executable as the executable for the running interpreter.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Find commands your shell can start<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The prompt&#8217;s command lookup and a running process can refer to different interpreters, so use the check that matches your task.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Windows Command Prompt and PowerShell<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In Command Prompt, use the Windows where utility to search the current directory and PATH for matching command files.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nwhere.exe python\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">where.exe searches the current directory and PATH. Its output lists matching files from those search locations.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In PowerShell, Get-Command can list every command named python and show its command type and source. Check the type before treating a result as an executable file.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nGet-Command python -All | Select-Object CommandType, Name, Source\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/learn.microsoft.com\/en-us\/windows-server\/administration\/windows-commands\/where\" target=\"_blank\" rel=\"noopener\">Microsoft documents where.exe<\/a> as searching the current directory and PATH for matching files. <a href=\"https:\/\/learn.microsoft.com\/en-us\/powershell\/module\/microsoft.powershell.core\/get-command?view=powershell-7.5\" target=\"_blank\" rel=\"noopener\">PowerShell&#8217;s Get-Command reference<\/a> covers aliases and functions, along with scripts and applications, so its output can include more than executable files.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Check CommandType before using Source as an executable path, because Alias and Function entries describe PowerShell commands.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">macOS and Linux shells<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In Bash or Zsh, type -a lists matching command names. The <a href=\"https:\/\/pubs.opengroup.org\/onlinepubs\/9799919799\/utilities\/command.html\" target=\"_blank\" rel=\"noopener\">Portable Operating System Interface (POSIX)<\/a> specifies that command -v reports how the shell interprets one name.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\ntype -a python3\ncommand -v python3\n<\/pre><\/div>\n\n\n<ul class=\"wp-block-list\">\n<li>Several results mean the shell can see several matches. Their order helps explain which command the shell selects.<\/li>\n\n\n<li>A shell result describes that shell&#8217;s command lookup. Use sys.executable inside the program to identify its running interpreter.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"464\" src=\"https:\/\/www.askpython.com\/wp-content\/uploads\/2023\/12\/image-11-1024x464.png\" alt=\"macOS Terminal output showing which python3 resolving to \/opt\/homebrew\/bin\/python3\" class=\"wp-image-57506\" style=\"width:590px;height:auto\" srcset=\"https:\/\/www.askpython.com\/wp-content\/uploads\/2023\/12\/image-11-1024x464.png 1024w, https:\/\/www.askpython.com\/wp-content\/uploads\/2023\/12\/image-11-300x136.png 300w, https:\/\/www.askpython.com\/wp-content\/uploads\/2023\/12\/image-11-768x348.png 768w, https:\/\/www.askpython.com\/wp-content\/uploads\/2023\/12\/image-11.png 1396w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">This path belongs to one macOS shell. Homebrew and other Python installers can use different locations.<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/docs.brew.sh\/Installation\" target=\"_blank\" rel=\"noopener\">Homebrew documents its default prefixes<\/a> for Apple Silicon and Intel Macs. Other Python distributions can use different directories.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Separate a virtual environment from base Python<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A virtual environment has its own Python executable and installation prefix. The <a href=\"https:\/\/docs.python.org\/3\/library\/venv.html\" target=\"_blank\" rel=\"noopener\">Python venv documentation<\/a> describes sys.prefix as the active environment prefix and sys.base_prefix as the base installation prefix.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport sys\n\nprint(&quot;executable:&quot;, sys.executable)\nprint(&quot;prefix:&quot;, sys.prefix)\nprint(&quot;base prefix:&quot;, sys.base_prefix)\nprint(&quot;inside a virtual environment:&quot;, sys.prefix != sys.base_prefix)\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">When the last line prints True, the interpreter is inside a virtual environment. Outside one, sys.prefix and sys.base_prefix normally match.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">sys.prefix is the active environment root, and its executable can be under bin on macOS or Linux or under Scripts on Windows.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">sys.base_prefix is the base installation root, and sys.executable is the active process&#8217;s executable.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Conda also selects Python per environment. The <a href=\"https:\/\/www.askpython.com\/python-modules\/python-anaconda-tutorial\">AskPython Anaconda tutorial<\/a> explains how its environments organize an interpreter and packages.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">When command lookup returns nothing<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The result describes the shell&#8217;s search locations. An IDE or a full-path launch can still start an interpreter outside those locations.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Situation<\/th><th>Next check<\/th><\/tr><\/thead><tbody><tr><td>Python starts from an IDE, but shell lookup is empty<\/td><td>Run sys.executable inside the IDE&#8217;s Python console<\/td><\/tr><tr><td>Python will not start from the shell<\/td><td>Check which interpreter the IDE or launcher is configured to use<\/td><\/tr><tr><td>You need package directories<\/td><td>Run python3 -m site with the interpreter in question<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Use the running interpreter as your final check<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Use sys.executable to identify the interpreter running the process, and run the site module with that same interpreter to inspect its library directories.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In Windows Command Prompt or PowerShell, use python. In a macOS or Linux shell, use python3.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The <a href=\"https:\/\/docs.python.org\/3\/library\/site.html\" target=\"_blank\" rel=\"noopener\">Python site reference<\/a> describes the directories printed by this command.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\npython -m site\npython3 -m site\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\">Frequently asked questions<\/h2>\n\n\n<div id=\"rank-math-faq\" class=\"rank-math-block\">\n<div class=\"rank-math-list \">\n<div id=\"faq-question-1790799469659\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \">Does sys.executable show the virtual environment&#8217;s Python?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>When Python runs inside a virtual environment, sys.executable points to that environment&#8217;s interpreter. sys.base_prefix identifies the base installation prefix.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1790799469660\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \">Is where.exe python the same as sys.executable?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>where.exe searches the current directory and PATH for matching files. sys.executable reports the executable running the current Python process.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1790799469661\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \">How do I find where Python installs packages?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>Run the site module through the interpreter used by your program. On Windows use python -m site, and on macOS or Linux use python3 -m site.<\/p>\n\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>An IDE can run Python even when `where.exe python` returns no match in a separate shell. I\u2019m intrigued that a blank lookup can coexist with a running interpreter. You can get the runtime path from the environment that launches your program. The first distinction is between a command your shell can find and the executable [&hellip;]<\/p>\n","protected":false},"author":77,"featured_media":71680,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-57504","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-examples"],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":8}},"_links":{"self":[{"href":"https:\/\/www.askpython.com\/wp-json\/wp\/v2\/posts\/57504","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.askpython.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.askpython.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.askpython.com\/wp-json\/wp\/v2\/users\/77"}],"replies":[{"embeddable":true,"href":"https:\/\/www.askpython.com\/wp-json\/wp\/v2\/comments?post=57504"}],"version-history":[{"count":1,"href":"https:\/\/www.askpython.com\/wp-json\/wp\/v2\/posts\/57504\/revisions"}],"predecessor-version":[{"id":71681,"href":"https:\/\/www.askpython.com\/wp-json\/wp\/v2\/posts\/57504\/revisions\/71681"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.askpython.com\/wp-json\/wp\/v2\/media\/71680"}],"wp:attachment":[{"href":"https:\/\/www.askpython.com\/wp-json\/wp\/v2\/media?parent=57504"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.askpython.com\/wp-json\/wp\/v2\/categories?post=57504"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.askpython.com\/wp-json\/wp\/v2\/tags?post=57504"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}