Python Embedding is optional and check install

.. make python embedding optional, if it's not installed then
   disable in preferences (new checkbox similar to R).
This commit is contained in:
Mark Liversedge
2018-02-05 16:27:00 +00:00
parent 8e5e95bfe4
commit 954570fe16
5 changed files with 32 additions and 1 deletions

View File

@@ -62,6 +62,19 @@ PythonEmbed::PythonEmbed(const bool verbose, const bool interactive) : verbose(v
// set the module path in the same way the interpreter would
PyObject *sys = PyImport_ImportModule("sys");
// did module import fail (python not installed)
if (sys == NULL) {
// abort embedding
QMessageBox msg(QMessageBox::Information, QObject::tr("Python not installed"),
QObject::tr("Python v3.6 or higher is required for Python.\nPython disabled in preferences."));
appsettings->setValue(GC_EMBED_PYTHON, false);
loaded=false;
msg.exec();
return;
}
PyObject *path = PyObject_GetAttrString(sys, "path");
PyList_Append(path, PyUnicode_FromString("."));