Reputation: 877
I created a script for hundreds of users. It includes this line:
os.execute("C:\\InstallPython\\python.exe "Path-to-current-folder-with-python-script")
This line is written in Lua language, but language doesn't matter.
User can install Python in any folder. It might be on Disc C or D. I don't know this.
How to create a universal version that suits all users?
Maybe I can get the path to python.exe by a program?
Upvotes: 2
Views: 213
Reputation: 339
Check out this: https://www.lua.org/pil/22.2.html
Usually path to python is in PYTHON_PATH
environment variable.
So you can try this in your Lua script before running the python script:
os.getenv("PYTHON_PATH")
Once you print this variable, you can see that it indeed includes the path where python was installed, the only thing you might do, is to add a python.exe
to this string, as it might point to a directory, not to the python executable.
In my case PYTHON_PATH
value is: C:\Python27\
when using Python2.7
Upvotes: 4
Reputation: 328
import sys
sys.executable
Above should return the path to the executable.
Python Docs
Upvotes: 0