Where is python installed on windows

I want to find out my Python installation path on Windows. For example:

C:\Python25

How can I find where Python is installed?

Stevoisiak's user avatar

Stevoisiak

24.1k28 gold badges122 silver badges226 bronze badges

asked Mar 15, 2009 at 9:09

Fang-Pen Lin's user avatar

Fang-Pen LinFang-Pen Lin

13.5k15 gold badges67 silver badges96 bronze badges

1

In your Python interpreter, type the following commands:

>>> import os
>>> import sys
>>> os.path.dirname(sys.executable)
'C:\\Python25'

Also, you can club all these and use a single line command. Open cmd and enter following command

python -c "import os, sys; print(os.path.dirname(sys.executable))"

Mrityunjai's user avatar

answered Mar 15, 2009 at 13:17

elo80ka's user avatar

13

If you have Python in your environment variable then you can use the following command in cmd or powershell:

 where python

or for Unix enviroment

 which python

command line image :

enter image description here

answered Apr 17, 2017 at 16:04

Aekansh Kansal's user avatar

Aekansh KansalAekansh Kansal

2,8291 gold badge15 silver badges17 bronze badges

3

It would be either of

  • C:\Python36
  • C:\Users\(Your logged in User)\AppData\Local\Programs\Python\Python36

answered Aug 18, 2017 at 9:52

Amol Manthalkar's user avatar

Amol ManthalkarAmol Manthalkar

1,9202 gold badges16 silver badges16 bronze badges

5

If you need to know the installed path under Windows without starting the python interpreter, have a look in the Windows registry.

Each installed Python version will have a registry key in either:

  • HKLM\SOFTWARE\Python\PythonCore\versionnumber\InstallPath
  • HKCU\SOFTWARE\Python\PythonCore\versionnumber\InstallPath

In 64-bit Windows, it will be under the Wow6432Node key:

  • HKLM\SOFTWARE\Wow6432Node\Python\PythonCore\versionnumber\InstallPath

yincrash's user avatar

yincrash

6,3941 gold badge40 silver badges41 bronze badges

answered Mar 15, 2009 at 21:08

codeape's user avatar

codeapecodeape

98.1k24 gold badges159 silver badges190 bronze badges

8

Simple way is

  1. open CMD
  2. type where python in cmd

Sorry for my bad English's user avatar

answered Jan 30, 2020 at 14:13

BigData-Guru's user avatar

BigData-GuruBigData-Guru

1,1711 gold badge15 silver badges20 bronze badges

2

If you have the py command installed, which you likely do, then just use the --list-paths/-0p argument to the command:

py --list-paths

Example output:

Installed Pythons found by py Launcher for Windows
-3.8-32 C:\Users\cscott\AppData\Local\Programs\Python\Python38-32\python.exe *
-2.7-64 C:\Python27\python.exe

The * indicates the currently active version for scripts executed using the py command.

answered Dec 9, 2019 at 20:48

carlin.scott's user avatar

carlin.scottcarlin.scott

6,2943 gold badges31 silver badges35 bronze badges

1

On my windows installation, I get these results:

>>> import sys
>>> sys.executable
'C:\\Python26\\python.exe'
>>> sys.platform
'win32'
>>>

(You can also look in sys.path for reasonable locations.)

answered Mar 15, 2009 at 10:18

gimel's user avatar

gimelgimel

83.6k10 gold badges77 silver badges105 bronze badges

2

Its generally

‘C:\Users\user-name\AppData\Local\Programs\Python\Python-version’

or
try using (in cmd )

where python

answered Apr 12, 2020 at 18:45

utkarsh2299's user avatar

In the sys package, you can find a lot of useful information about your installation:

import sys
print sys.executable
print sys.exec_prefix

I’m not sure what this will give on your Windows system, but on my Mac executable points to the Python binary and exec_prefix to the installation root.

You could also try this for inspecting your sys module:

import sys
for k,v in sys.__dict__.items():
    if not callable(v):
        print "%20s: %s" % (k,repr(v))

answered Mar 15, 2009 at 9:41

Guðmundur H's user avatar

Guðmundur HGuðmundur H

11.5k3 gold badges24 silver badges22 bronze badges

2

If You want the Path After successful installation then first open you CMD and type
python or python -i

It Will Open interactive shell for You and Then type

import sys

sys.executable

Hit enter and you will get path where your python is installed …

Community's user avatar

answered Oct 18, 2018 at 7:30

Rutvik Vijaybhai Bhimani's user avatar

1

To know where Python is installed you can execute where python in your cmd.exe.

anothernode's user avatar

anothernode

5,16113 gold badges45 silver badges63 bronze badges

answered Jul 27, 2018 at 6:21

4

You can search for the «environmental variable for you account». If you have added the Python in the path, it’ll show as «path» in your environmental variable account.

but almost always you will find it in
«C:\Users\%User_name%\AppData\Local\Programs\Python\Python_version»

the ‘AppData‘ folder may be hidden, make it visible from the view section of toolbar.

answered Sep 14, 2018 at 9:19

Amit Gupta's user avatar

Amit GuptaAmit Gupta

2,7084 gold badges24 silver badges37 bronze badges

Make use of the Python Launcher for Windows (available as of 3.3). It is compatible with all available versions of python.

First, check if the launcher is available:

py 

starts the latest installed version of Python

To see all Python versions available on your system and their path:

py -0p

or

py --list-paths

For a specific Python version path—especially useful with multiple python installations:

py -3.7 -c "import os, sys; print(os.path.dirname(sys.executable))"

python 2

py -2 -c "import os, sys; print(os.path.dirname(sys.executable))"

py installed location is C:\Windows\py.exe if installed for all users, otherwise can be found at C:\Users\username\AppData\Local\Programs\Python\Launcher.
It does not require the environment PATH variable to be set if installed for all users.

answered Apr 25, 2022 at 2:23

oyeyipo's user avatar

oyeyipooyeyipo

3693 silver badges11 bronze badges

You can find it in the Windows GUI, but you need to select “show hidden” in the menu. Directory where python is installed on my Win10 computer:

C:\Users\username\AppData\Local\Programs\Python\Python310

Very handy if you use python pip to install packages.

Suraj Rao's user avatar

Suraj Rao

29.4k11 gold badges94 silver badges103 bronze badges

answered Dec 31, 2021 at 14:35

Wingrider07's user avatar

1

If anyone needs to do this in C# I’m using the following code:

static string GetPythonExecutablePath(int major = 3)
{
    var software = "SOFTWARE";
    var key = Registry.CurrentUser.OpenSubKey(software);
    if (key == null)
        key = Registry.LocalMachine.OpenSubKey(software);
    if (key == null)
        return null;

    var pythonCoreKey = key.OpenSubKey(@"Python\PythonCore");
    if (pythonCoreKey == null)
        pythonCoreKey = key.OpenSubKey(@"Wow6432Node\Python\PythonCore");
    if (pythonCoreKey == null)
        return null;

    var pythonVersionRegex = new Regex("^" + major + @"\.(\d+)-(\d+)$");
    var targetVersion = pythonCoreKey.GetSubKeyNames().
                                        Select(n => pythonVersionRegex.Match(n)).
                                        Where(m => m.Success).
                                        OrderByDescending(m => int.Parse(m.Groups[1].Value)).
                                        ThenByDescending(m => int.Parse(m.Groups[2].Value)).
                                        Select(m => m.Groups[0].Value).First();

    var installPathKey = pythonCoreKey.OpenSubKey(targetVersion + @"\InstallPath");
    if (installPathKey == null)
        return null;

    return (string)installPathKey.GetValue("ExecutablePath");
}

answered Apr 5, 2017 at 11:10

Peter's user avatar

PeterPeter

37.1k39 gold badges142 silver badges199 bronze badges

2

This worked for me: C:\Users\Your_user_name\AppData\Local\Programs\Python

My currently installed python version is 3.7.0

Hope this helps!

David's user avatar

David

1,1925 gold badges13 silver badges31 bronze badges

answered Jul 16, 2018 at 6:55

Prashant Gonga's user avatar

Go to C:\Users\USER\AppData\Local\Programs\Python\Python36
if it is not there then
open console by windows+^R
Then type cmd and hit enter
type python if installed in your local file it will show you its version from there type the following
import os
import sys
os.path.dirname(sys.executable)

answered Mar 1, 2019 at 11:34

SATYAJIT MAITRA's user avatar

You could have many versions of Python installed on your machine. So if you’re in Windows at a command prompt, entering something like this…

py --version

…should tell you what version you’re using at the moment. (Maybe replace py with python or python3 if py doesn’t work). Anyway you’d see something like

Python 3.10.2

If you then create a virtual environment using something like this…

py -m venv venv

…that environment will also use that Python version. To verify, activate the environment…

venv\scripts\activate.bat 

You’ll see the name of the command prompt. Now if execute:

where python

…it will show you which Python executable that virtual environment uses. It will be a copy of Python.exe what’s actually in the Scripts subfolder of the virtual environment folder. Of course to see which version that is, again use py --version.

answered Jan 26, 2022 at 15:55

Alan Simpson's user avatar

if you still stuck or you get this

C:\\\Users\\\name of your\\\AppData\\\Local\\\Programs\\\Python\\\Python36

simply do this replace 2 \ with one

C:\Users\akshay\AppData\Local\Programs\Python\Python36

Kos's user avatar

Kos

4,9209 gold badges38 silver badges42 bronze badges

answered Jun 2, 2018 at 16:48

Ashwarya sharma's user avatar

I installed 2 and 3 and had the same problem finding 3. Fortunately, typing path at the windows path let me find where I had installed it. The path was an option when I installed Python which I just forgot. If you didn’t select setting the path when you installed Python 3 that probably won’t work — unless you manually updated the path when you installed it.
In my case it was at c:\Program Files\Python37\python.exe

answered Feb 3, 2019 at 16:39

Douglas Gilliland's user avatar

If you use anaconda navigator on windows, you can go too enviornments and scroll over the enviornments, the root enviorment will indicate where it is installed. It can help if you want to use this enviorment when you need to connect this to other applications, where you want to integrate some python code.

answered Jun 6, 2019 at 10:01

PV8's user avatar

PV8PV8

5,8627 gold badges43 silver badges88 bronze badges

Option 1 : Check System Environment Variables > Path

Option 2 : C:\Users\Asus\AppData\Local\Programs\Python (By default Path)

answered Oct 1, 2022 at 10:09

Jigyanshu Chouhan's user avatar

On my Windows 11, I have two Python installed: 3.11.2 and 3.8. The below commends give only one of them.

Which python

which py

To find out the location of both the below Powershell commands come in handy:

$User = New-Object System.Security.Principal.NTAccount($env:UserName)

$sid = $User.Translate([System.Security.Principal.SecurityIdentifier]).value

New-PSDrive HKU Registry HKEY_USERS

Get-ChildItem "HKU:\${sid}\Software\Python\PythonCore\*\InstallPath"

answered Mar 27 at 23:26

Harry Zhang's user avatar

Python supported various inbuilt and open-source modules. To use these modules and their functions, we need to import them at the start of the program. The Python interpreter will not import these modules if we don’t add a Python path to the window path. It is necessary to find the Python paths and map them to Windows otherwise; these modules can not be accessible in the Python program.

To find the Python path or where Python is installed on windows, various functions are used, such as using the “where python” command in the cmd terminal, using system properties, etc.

This post provides multiple methods to find installed Python paths on windows:

  • Method 1: Using CMD Terminal
  • Method 2: Using the sys Library
  • Method 3: Using Windows Startup Menu
  • Method 4: Using System Properties

Method 1: Using CMD Terminal

The path of the installed Python can be found using the following command in cmd terminal:

Using where python

The easiest way to find where Python is installed on windows is using “where python” command in cmd terminal:

The above snippet shows the path of the installed Python.

Using py –list-paths

The “py –list-paths” command can be used as an alternative to getting the installation path of installed Python:

The path of the installed Python has been displayed successfully.

Method 2: Using the sys Library

The “sys” library interacts with the Python interpreter and runtime environment through various functions. The “sys.exec_prefix” is used to find the path of the installed Python:

Code:

import sys
print(sys.exec_prefix)

The “sys” module is imported. The “sys.exec_prefix” is passed as an argument to print() function to show the installed Python path.

Output:

The installed Python path has been displayed.

Method 3: Using Windows Startup Menu

The third simple method to find where Python is installed on windows is using the startup menu search. To open a Python-installed path, you need to type “python.exe” in the search bar and click on the “open the file location” option.

The Python-installed path has been opened, and the “exe” file shows the installed Python. 

Method 4: Using System Properties

The manual way of opening the installed Python path is done using the system properties of the system. But this method is only applicable if your Python path is added to the windows path at the time of installation or later. To add Python to the windows path, check this specific guide.

Now after adding the Python path to the window path, you can follow the below steps to get the Python installation path:

Step 1: Open the Run dialog box and type “sysdm.cpl” in the run dialog box: 

Step 2: Select environment variables from the advanced option.

Step 3: Select the Python path and click on the “Edit” button.

Step 4: The path of all installed Python is located in the environment variable setting.

Conclusion

To find where Python is installed on windows, various methods such as CMD terminal, sys library, startup menu search, and system properties are used in Python. The “where python” and “py –list-paths” commands are used to get the installed Python path. Similarly, opening the file location of the “python.exe” file from the start menu search will also open the installed Python path. This post presented various methods to find where Python is installed on Windows.

Иногда нам нужно проверить пакеты или модули в том месте, где установлен Python. В этой статье мы покажем три способа, как найти папку в которой установлен Python в Windows:

  • с помощью командной строки
  • через меню “Пуск
  • используя параметры переменной среды

Итак, давайте начнем!

Примечание редакции: о собственно установке Python читайте в статье “Как установить Python на Windows 10 или 11”.

Чтобы узнать, где установлен Python, используя командную строку Windows, следуйте приведенным ниже примерам.

Пример 1: команда where

Для начала попробуйте использовать команду where, чтобы вывести путь к директории установленного Python:

>where python

Как видите, в результате нужный путь был найден и отображен в командной строке:

Использование where  в командной строке. На следующей строке после введенной команды выведен путь, по которому  в Windows установлен Python

Пример 2: команда py

Команда py с опцией --list-paths также может быть использована для перечисления путей к Python:

Использование команды py --list-paths в командной строке

Как найти место установки Python в Windows с помощью меню “Пуск”

Чтобы найти, где установлен Python, используя меню “Пуск”, выполните следующую процедуру.

Сначала найдите файл “Python.exe” в меню “Пуск”. Затем выберите опцию “Открыть расположение файла”, чтобы открыть соответствующую папку:

Опция "Open file location" в меню "Пуск".

В результате вы будете перемещены в каталог, где установлен Python:

Каталог, где установлен Python

Как найти место установки Python в Windows с помощью переменной окружения

Чтобы узнать, где установлен Python, используя переменную окружения PATH, выполните следующие действия.

Шаг 1. Откройте расширенные системные настройки

Нажмите Window+I, чтобы открыть Настройки системы. Затем выберите “Система” из списка доступных категорий:

Окно настроек

Найдите в строке поиска “Дополнительные параметры системы” и откройте их:

Дополнительные параметры системы

Шаг 2. Откройте переменные среды

В Дополнительных параметрах системы нажмите на кнопку “Переменные среды”:

Переменные среды

Шаг 3. Откройте переменную среды Path

На вкладке “Системные переменные” выберите “Path” и нажмите кнопку “Изменить” для просмотра сведений о пути:

Вкладка "Системные переменные"

Из переменной среды Path можно найти место, где установлен Python, как показано ниже:

Окно редактирования переменной окружения с выделенным путем к Python

Заключение

Узнать, где в Windows установлен Python, можно разными способами, например, с помощью командной строки, меню “Пуск” и системных переменных среды.

Для первого способа откройте командную строку и воспользуйтесь командой where python. Во втором случае найдите “python.exe” в меню “Пуск” и откройте местоположение файла. При третьем подходе вы можете узнать расположение Python через переменную среды “Path”.

Перевод статьи Rafia Zafar «How Can I Find Where Python is Installed on Windows».

In this short guide, you’ll see two methods to find where Python is installed on Windows:

  • Using the sys library
  • Manually

Find Where Python is Installed on Windows using the Sys Library

You can use the sys library in order to find where Python is installed:

import sys

print(sys.exec_prefix)

Here is an example of a path structure that you may get:

C:\Users\Ron\AppData\Local\Programs\Python\Python311

Manually Locate Where Python is Installed

Alternatively, you can manually locate where Python is installed by following these steps:

  1. Type ‘Python’ in the Windows Search Bar
  2. Right-click on the Python App, and then select “Open file location
  3. Right-click again on the Python shortcut, and then select “Open File Location

You’ll now get the location/path where your Python is installed on Windows:

C:\Users\Ron\AppData\Local\Programs\Python\Python311

Notice that the path under this method matches to the path found under the first method.

Once you retrieved the above path, you’ll be able to upgrade pip for example.

To find where Python is installed on Windows, you can follow these steps:

  1. Open the Windows Start menu and search for «Environment Variables».
  2. Click on «Edit the system environment variables» button.
  3. Click on the «Environment Variables» button.
  4. In the «System Variables» section, scroll down and find the «Path» variable.
  5. Click on the «Edit» button.
  6. This will open the «Edit environment variable» window. Click on the «New» button and enter the path to the Python installation. For example: C:\Python38\

Alternatively, you can use the where command in the command prompt to find the location of the Python executable. Here’s an example:

C:\> where python
C:\Python38\python.exe

This will print the path to the Python executable.

If you have multiple versions of Python installed, the where command will show the location of all of them. You can specify a specific version of Python by including the version number in the command, like this:

C:\> where python3.8
C:\Python38\python.exe

This will print the path to the Python 3.8 executable.

  • Where is hosts file in windows
  • Where to buy windows 10
  • Wifi buzuvchi programma windows 10
  • Where is docker volumes in windows
  • Where is docker images windows