Как найти где установлен python

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

23k27 gold badges120 silver badges222 bronze badges

asked Mar 15, 2009 at 9:09

Fang-Pen Lin's user avatar

Fang-Pen LinFang-Pen Lin

13.1k15 gold badges66 silver badges95 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,6791 gold badge14 silver badges17 bronze badges

3

It would be either of

  • C:Python36
  • C:Users(Your logged in User)AppDataLocalProgramsPythonPython36

answered Aug 18, 2017 at 9:52

Amol Manthalkar's user avatar

Amol ManthalkarAmol Manthalkar

1,8501 gold badge16 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:

  • HKLMSOFTWAREPythonPythonCoreversionnumberInstallPath
  • HKCUSOFTWAREPythonPythonCoreversionnumberInstallPath

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

  • HKLMSOFTWAREWow6432NodePythonPythonCoreversionnumberInstallPath

yincrash's user avatar

yincrash

6,3241 gold badge39 silver badges41 bronze badges

answered Mar 15, 2009 at 21:08

codeape's user avatar

codeapecodeape

97.1k24 gold badges156 silver badges186 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,1211 gold badge14 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:UserscscottAppDataLocalProgramsPythonPython38-32python.exe *
-2.7-64 C:Python27python.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

5,9343 gold badges28 silver badges34 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

82.6k10 gold badges76 silver badges104 bronze badges

2

Its generally

‘C:Usersuser-nameAppDataLocalProgramsPythonPython-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.2k3 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

4,97811 gold badges43 silver badges60 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%AppDataLocalProgramsPythonPython_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,6604 gold badges23 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:Windowspy.exe if installed for all users, otherwise can be found at C:UsersusernameAppDataLocalProgramsPythonLauncher.
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

3493 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:UsersusernameAppDataLocalProgramsPythonPython310

Very handy if you use python pip to install packages.

Suraj Rao's user avatar

Suraj Rao

29.3k11 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(@"PythonPythonCore");
    if (pythonCoreKey == null)
        pythonCoreKey = key.OpenSubKey(@"Wow6432NodePythonPythonCore");
    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

36.7k38 gold badges141 silver badges197 bronze badges

2

This worked for me: C:UsersYour_user_nameAppDataLocalProgramsPython

My currently installed python version is 3.7.0

Hope this helps!

David's user avatar

David

1,1825 gold badges13 silver badges30 bronze badges

answered Jul 16, 2018 at 6:55

Prashant Gonga's user avatar

Go to C:UsersUSERAppDataLocalProgramsPythonPython36
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…

venvscriptsactivate.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:UsersakshayAppDataLocalProgramsPythonPython36

Kos's user avatar

Kos

4,8709 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 FilesPython37python.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,5266 gold badges41 silver badges79 bronze badges

Option 1 : Check System Environment Variables > Path

Option 2 : C:UsersAsusAppDataLocalProgramsPython (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}SoftwarePythonPythonCore*InstallPath"

answered Mar 27 at 23:26

Harry Zhang's user avatar

Иногда нам нужно проверить пакеты или модули по пути, где установлен 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».

Python is on my machine, I just don’t know where, if I type python in terminal it will open Python 2.6.4, this isn’t in it’s default directory, there surely is a way of finding it’s install location from here?

Cœur's user avatar

Cœur

36.8k25 gold badges192 silver badges260 bronze badges

asked Jul 20, 2011 at 19:19

Kilizo's user avatar

1

sys has some useful stuff:

$ python
Python 2.6.6 (r266:84297, Aug 24 2010, 18:13:38) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.executable
'c:\Python26\python.exe'
>>> sys.exec_prefix
'c:\Python26'
>>>
>>> print 'n'.join(sys.path)

c:Python26libsite-packagessetuptools-0.6c11-py2.6.egg
c:Python26libsite-packagesnose-1.0.0-py2.6.egg
C:Windowssystem32python26.zip
c:Python26DLLs
c:Python26lib
c:Python26libplat-win
c:Python26liblib-tk
c:Python26
c:Python26libsite-packages
c:Python26libsite-packageswin32
c:Python26libsite-packageswin32lib
c:Python26libsite-packagesPythonwin
c:Python26libsite-packageswx-2.8-msw-unicode

answered Jul 20, 2011 at 19:24

Ned Batchelder's user avatar

Ned BatchelderNed Batchelder

361k72 gold badges559 silver badges658 bronze badges

6

In unix (mac os X included) terminal you can do

which python

and it will tell you.

Vega's user avatar

Vega

27.5k27 gold badges94 silver badges101 bronze badges

answered Jul 20, 2011 at 19:21

dhg's user avatar

dhgdhg

52.3k8 gold badges123 silver badges144 bronze badges

8

Platform independent solution in one line is

Python 2:

python -c "import sys; print sys.executable"

Python 3:

python -c "import sys; print(sys.executable)"

FistOfFury's user avatar

FistOfFury

6,6277 gold badges49 silver badges57 bronze badges

answered Jul 20, 2011 at 20:01

schlamar's user avatar

schlamarschlamar

9,1903 gold badges37 silver badges76 bronze badges

2

For Windows CMD run: where python

For Windows PowerShell run: Get-Command python

answered May 17, 2017 at 9:34

SitiSchu's user avatar

SitiSchuSitiSchu

1,36111 silver badges20 bronze badges

5

Have a look at sys.path:

>>> import sys
>>> print(sys.path)

answered Jul 20, 2011 at 19:25

MRAB's user avatar

MRABMRAB

20.2k6 gold badges40 silver badges33 bronze badges

2

On UNIX-like systems, you should be able to type which python, which will print out the path to python. The equivalent in Windows Command Prompt is where python, and Get-Command python in Windows Powershell.

Another (cross-platform) method is to type this into IDLE or REPL (type python into your terminal):

import re
re.__file__

Or in one line from your terminal:

python -c "import re; print(re.__file__)"

This will print the path to the re module, consequently showing you where the python command points to. You can put any other module that you know is installed, and the path will point to that module, also giving you the path to python.

Xbox One's user avatar

Xbox One

3092 silver badges13 bronze badges

answered Jul 20, 2011 at 19:23

tiny_mouse's user avatar

tiny_mousetiny_mouse

4792 silver badges9 bronze badges

7

To find all the installations of Python on Windows run this at the command prompt:

dir site.py /s

Make sure you are in the root drive. You will see something like this.

answered Dec 2, 2015 at 15:35

Webucator's user avatar

WebucatorWebucator

2,32722 silver badges35 bronze badges

If you are using wiindows OS (I am using windows 10 ) just type

where python   

in command prompt ( cmd )

It will show you the directory where you have installed .

answered Apr 25, 2020 at 8:23

Badri Paudel's user avatar

Badri PaudelBadri Paudel

1,29516 silver badges19 bronze badges

For Windows Users:

If the python command is not in your $PATH environment var.

Open PowerShell and run these commands to find the folder

cd 
ls *ython* -Recurse -Directory

That should tell you where python is installed

answered Oct 24, 2017 at 20:06

Kellen Stuart's user avatar

Kellen StuartKellen Stuart

7,4857 gold badges56 silver badges82 bronze badges

5

  1. First search for PYTHON IDLE from search bar
  2. Open the IDLE and use below commands.

    import sys
    print(sys.path)

  3. It will give you the path where the python.exe is installed. For eg:
    C:Users\…python.exe

  4. Add the same path to system environment variable.

answered Mar 18, 2020 at 7:24

Anku g's user avatar

Anku gAnku g

1018 bronze badges

0

On windows search python,then right click and click on “Open file location”.That’s how I did

answered Aug 13, 2019 at 5:14

0

Run below command

where python

Ahmet Emre Kilinc's user avatar

answered Oct 11, 2022 at 12:01

Mounesh's user avatar

MouneshMounesh

4795 silver badges18 bronze badges

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

  • Using the sys library
  • Manually

Use the Sys Library to Find Where Python is Installed on Windows

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

import sys

locate_python = sys.exec_prefix

print(locate_python)

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

C:UsersRonAppDataLocalProgramsPythonPython39

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 on the Python shortcut, and then select Properties
  4. Click on “Open File Location

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

C:UsersRonAppDataLocalProgramsPythonPython39

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.

  1. HowTo
  2. Python How-To’s
  3. Where Is Python Installed

Manav Narula
Oct 15, 2021
Mar 14, 2021

  1. Use the dirname() Function to Find the Installation Folder of Python
  2. Use the where Command to Find the Installation Folder of Python
  3. Use the which Command to Find the Installation Folder of Python

Where Is Python Installed

The installation folder of any software or application has some significance since it points us to the exact place where most of the related files and folders related to it can be found. The same goes for Python; we have to install it at a specific location where it stores the language’s modules and basic framework.

In this tutorial, we will learn how to view the path of the installation folder of Python.

Use the dirname() Function to Find the Installation Folder of Python

The os library is used to interact with the Operating System and has functions available to retrieve full paths of the files. The dirname() function from this library can be used to retrieve the directory from the specified file’s path.

To return the installation directory, we pass the sys.executable to this function from the sys library. The sys.executable returns the path of the binary executable of the Python interpreter.

The following code shows how to use this.

import os
import sys

print(os.path.dirname(sys.executable))

Output:

Use the where Command to Find the Installation Folder of Python

We can directly use the where python command in the command prompt to find Python’s installation folder in windows.

C:>where python
C:PythonPython 3.9python.exe

Use the which Command to Find the Installation Folder of Python

In Linux and macOS, we can use the which python command in the terminal to view Python’s installation path.

Manav Narula avatar
Manav Narula avatar

Manav is a IT Professional who has a lot of experience as a core developer in many live projects. He is an avid learner who enjoys learning new things and sharing his findings whenever possible.

LinkedIn

Related Article – Python Installation

  • Install Python Module Within Code
  • Install Python Package Without Pip
  • Install Python on Linux
  • Create requirements.txt in Python
  • Python Default Install Location
  • Methods to Update Python on Mac

Ezoic

Добавить комментарий