Locate python home

Thomas Aanensen thoaan at stud.cs.uit.no
Wed Feb 25 11:31:57 CET 2004


> Never trust the assumption:
>
>  >>> import os
>  >>> os.path.isfile( os.path.join(os.path.dirname( sys.executable ),
> 'python.exe' ))
> False
>
> (This is from within Pythonwin, which has its executable elsewhere).
>
> It's a good idea to check and see if the file really does exist.  If it
> doesn't, either raise an error to tell the user to figure out what's
> wrong, or use the executable as given, (possibly checking/raising the
> error *only* if the executable is named pythonw and you can't find the
> python executable, though that would still have you running PythonWin in
> the above example (checking for "not named python" would be safer)).


What about using PYTHONHOME as environment variable. Is that appropriate?

Thomas





More information about the Python-list mailing list