diff --git a/Cantera/src/base/ct2ctml.cpp b/Cantera/src/base/ct2ctml.cpp index 4064ed126..e3ac5eb37 100644 --- a/Cantera/src/base/ct2ctml.cpp +++ b/Cantera/src/base/ct2ctml.cpp @@ -61,14 +61,19 @@ namespace ctml { static string pypath() { string s = "python"; const char* py = getenv("PYTHON_CMD"); + + // Try to source the "setup_cantera" script from the user's home + // directory in order to set PYTHON_CMD. if (!py) { const char* hm = getenv("HOME"); - string home = stripws(string(hm)); - string cmd = string(". ")+home - +string("/setup_cantera &> /dev/null"); + if (hm) { + string home = stripws(string(hm)); + string cmd = string(". ") + home + +string("/setup_cantera &> /dev/null"); system(cmd.c_str()); + } py = getenv("PYTHON_CMD"); - } + } if (py) { string sp = stripws(string(py)); if (sp.size() > 0) {