Where Is Python Installed On Windows?(Explained)

Where Is Python Installed On Windows? (Explained)

If you went outside and saw a python in your path, that would not be good. But we’re talking about whether Python is in the Windows PATH, a list of places where Windows looks for software.

At the command prompt, enter Python. Python should start if it is in your PATH:

• Proceed to the next section if you saw Python startup; if you got an error message instead, you could add Python to your PATH by following the steps below.

• Enter python.exe into the Windows search bar, but do not select it from the menu, right-click on it and select “Open file location.”

• A window with some files and folders will appear. Python should be installed here. Right-click the address bar at the top and select “Copy address as text.”

• Keep in mind that if the address bar says “Start menu,” you’re probably looking at a Python shortcut.

Right-click on the file called Python 3.x (where 3.x is the version number of your Python installation) and select Open file location until you see a folder with a file called python.exe in it.

Select Control Panel from the main Windows menu:

• In the top right search box, type “environment” and click “Edit environment variables for your account” in the results list.

• If a variable named Path is already listed, select it by clicking on it, then click Edit, if it does not exist, click New instead.

• If your pop-up window looks like the one below, click “New” and paste the address you just copied. Then click New, paste the address again, and add Scripts at the end. To finish editing your environment variables, click OK twice.

• If your pop-up box only has one line for the variable value, type a semicolon (;), then paste the address again and add Scripts at the end. To finish making changes to the environment variables, click OK.

• If the command prompt window is still open, close it and reopen it; this ensures that the changes you made at the command prompt have taken effect.

• At the command prompt, type python again and press the Enter key. Python should now be available for use. Ctrl+c will exit the Python shell.

How to Determine the Windows Path Where Python is Installed?

Python is usually installed on Windows in one of two locations:

• C: Python39

• C:UsersYourUserAppDataLocalProgramsPythonPython39

This article explains how to check if it is different for you because I’d go with the second option.

Before you start, consider the following:

• Do you have a Python interpreter or shell available?

• Do you have access to a command line or PowerShell?

• Do you have both?

Where Is Python Installed On Windows? (Explained)
Where Is Python Installed On Windows? (Explained)

Have you got access to a Python shell?

Run the following two lines in your shell to get the installation path in a readable format.

Python shell:

1. Use the following command to import the os and sys libraries: 

Import os, sys

2. Use the following command to print the path to the shell: print(os.path.dirname(sys. executable))

The following piece of code shows this:

import os, sys

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

The computer displays the following installation path:

‘C:\Users\xcent\AppData\Local\Programs\Python\Python39’

You can copy it to the clipboard and use it wherever you want.

There is a shorter way, but the output is not as good, using double front-slash path delimiters:

import sys

print (sys. executable)

On the computer, you can see the output in a Python shell:

import sys

print(sys.executable)

‘C:\\Users\\xcent\\AppData\\Local\\Programs\\Python\\Python39\\pythonw.exe’

Do you have access to a command line or Powershell?

For Windows, you can get the Python installation path by putting the Python code into a short, easy-to-copy one-liner command:

Python -c “import os and sys; print(os.path.dirname(sys.executable))”

If Python is permanently installed, you can run the python command in PowerShell from any directory, which is very useful.

You can also use the simple two-word command “where Python” in the Windows command line to determine where Python is installed. On a Windows computer, it works like this:

Where does Python appear?

This lets the following results:

C:\Users\xcent\AppData\Local\Microsoft\WindowsApps\python.exe

Next, you’ll discover a method for determining where Python is installed even if you don’t have access to the Python interpreter or the Windows command line.

Get Python’s Installation Path Without Using a Shell

If you don’t want to use the Python interpreter or the command line to find out where Python is installed on Windows, you can check in the Windows registry, which has a key for each installed Python version. Both of these variants are feasible:

• HKLMSOFTWAREPythonPythonCoreversionnumber

InstallPath

• HKCUSOFTWAREPythonPythonCoreversionnumber

InstallPath

If you have a 64-bit version of Windows, look under the Wow6432Node key for the Python path:

• HKLMSOFTWAREWow6432NodePythonPythonCoreversionnumberInstallPath

This post explains how to use these various variants in your code. For example, a more in-depth discussion can be found on the official Python wiki.

Python’s Default installs Location.

1.

This guide demonstrates how to install Python on a Windows computer.

The Python installer asks if the installation directory should be changed like any other directory. For example, the user can tell the installer where to install Python if it does.

Python can usually be installed in one of the following directories:

• C:UsersAppData

• C:PythonXY

• C:Program Files

This article will concentrate on these directories and the directories for installing Python in all three of them.

Install Python On the User’s AppData Directory

This means that you do not need to be an administrator to install the software. All you have to do is decide where you want to install it.

The issue with installing software in this directory is that it can only be accessed and used by one user. However, other users may be required to reinstall the software for another user.

Python is installed in the C:Program Files directory.

Python can be installed in the Program Files directory, the default location for all other Windows programs. It is an excellent option for those who want to install Python for more than one user simultaneously.

It does, however, have some drawbacks because of the new security features that have been added to newer versions of Windows. For example, the permissions for the Program Files subfolder are restricted, which may prevent some packages from installing or being used.

Installing Python in the C:\Program Files Directory

Installing Python in the directory’s root makes it easier to remember and type on the command line. It is similar to the directory mentioned above in that all users, not just the person who installed Python, can use the installed software.

One major issue with installing Python in the root directory is that it makes the computer less secure. Anyone with access to the user can easily find and use the root directory, making it less secure. You must also be an administrator to install Python in this directory.

How to Determine Where Python is Installed on Windows

This section of the guide will show you two ways to find out where Python is installed on Windows:

• Using the sys library

• Manually

Using the Sys Library, you can find where Python is installed on Windows.

The sys library can find you where Python is installed:

Import sys

locate python = sys.exec prefix

print(locate Python)

Here’s an example of a possible path structure:

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

Manually locate Python’s installation location.

You can also manually find out where Python is installed by following these steps:

In Windows, enter “Python” into the search box.

Right-click the Python App and select “Open file location.”

Right-click the Python shortcut and select Properties.

Click “Open File Location.”

You will now find where Python is installed on Windows:

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

Notice how the path in this method is the same as the path in the first method.

Once you have the above path, you will be able to do things like upgrade pip.

Conclusion

Hope this post helps you and if you have questions about anything concerning this topic, please leave them in the comment section below. Please use the social buttons to share this post with others. Thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *