I recently got python downloaded in my system. able to open all terminals, Idle windows able to access Pycharm. but really not sure where is the exact location of Python installed when i try to check from Command prompt. I wanted to add Environmental Variables. Please help.
You can use the
py command in a windows terminal and then you do not need to chage your PATH. Does that help?
- Find the Path to Python:
First, find out where Python is installed on your system. Typically, the default path is
C:\Python39 on Windows or
/usr/bin/python3 on Linux. Make sure to
replace these paths with the ones corresponding to your installation.
2. Copy the Python Path:
Copy the full path to the folder where Python is installed.
3. Add to PATH on Windows:
On Windows, right-click on the Computer or This PC icon and select “Properties.”
Click on “Advanced system settings” and then “Environment Variables.”
In the “System variables” section, find the variable called “Path” and click “Edit.”
Click “New” and add the path you copied earlier.
Click “OK” in all windows to confirm the changes.
4. Check if It’s Working:
Open a new terminal and type
python3. It should start the Python interpreter.
thank you so much @barry-scott
The default is in
c:\program files\python something these days.
The exact location will depend on what OS you’re using and how you installed it.
However, you can check from inside Python itself, on any platform, using
sys.executable. The docs mention that it’s possible for this
None if the executable location is unknown, but I’ve never encountered a situation in which that would happen during normal usage.
If you’re on Windows specifically and you used the official installer package from Download Python | Python.org, you should also have the special
py.exe “launcher” program, which helps reduce the need for changing environment variables. See 4. Using Python on Windows — Python 3.12.0 documentation.