0

Is there a way to find out where is my python installed using OS?

Well i know that if we open a shell and run this:

import os
os.getcwd()

it will work but can we do this in idle too ?

when its saved on desktop for example ?

actually I'm looking for this output for example:

C:\Users\user\AppData\Local\Programs\Python\Python37
3
  • 1
    os.getcwd returns your current working directory, not the location of either your script or the Python executable. Commented Apr 5, 2019 at 11:17
  • sys.executable returns the path of Python itself; sys.argv[0] is the location of the script (though it may be a path relative to you current working directory) when applicable. Commented Apr 5, 2019 at 11:19
  • what exactly are you after? Where your python script is stored? or your working directory when you try to run the script? Commented Apr 5, 2019 at 11:39

1 Answer 1

3

Try :

>>> import sys
>>> print sys.prefix
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.