To get the path of python.exe that is currently running this script .py file: sys.base_prefix
Console
import sys
sys.base_prefix
result
'C:\\python-3.7.4.amd64'
P.S.
On the other hand, to get the path of this script .py file running in Python: __file__
test.py
print(__file__)
result
'C:\\test.py'
Recommended Posts