title: How to print the name of the DLL which is unable to import?
body: <p>In my MFC application I am using the below line of code to import a python module.</p>
  
  <pre><code>pyImportedModuleObj = PyImport_Import(pyNameFilenameObj);
  </code></pre>
  
  <p>Even though the path is right, I am getting NULL. It is because of a python exception. I have tried to print the actual python exception. </p>
  
  <pre><code>    bool CheckPythonError() {
          if (PyObject *perr = PyErr_Occurred()) {
              PyObject *errobj, *errdata, *errtraceback, *pyerr, *pydata, *pytrc;
  
              PyErr_Fetch(&amp;errobj, &amp;errdata, &amp;errtraceback);
              pyerr = NULL;
              pydata = NULL;
              CString save_error_type, save_error_data, save_traceback;
              if (errobj != NULL &amp;&amp;
              (pyerr = PyObject_Str(errobj)) != NULL &amp;&amp;     /* str(object) */
              (PyString_Check(pyerr))) {
                  save_error_type = PyString_AsString(pyerr);
                  pydata = PyObject_Str(errdata);
                  PyString_Check(pydata);
                  save_error_data = PyString_AsString(pydata);
                  pytrc = PyObject_Str(errtraceback);
                  if (errtraceback) {
                      save_traceback = PyString_AsString(errtraceback);
                  }
                  else {
                      save_traceback = "No traceback available";
                  }
              }
              else {
                  save_error_type = "&lt;unknown exception type&gt;";
              }
              Py_XDECREF(pyerr);
              Py_XDECREF(pydata);
              //WI-29387 - Replaced MessageBox with g_MsgBoxMgr.ShowMessageBox
              MessageBox(NULL, save_error_type + "\n" + save_error_data, "Error", MB_OK | MB_ICONINFORMATION);
              return TRUE;
          }
          return FALSE;
      }
  </code></pre>
  
  <p>I am getting the python error as below.</p>
  
  <p><a href="https://i.stack.imgur.com/YRbaN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YRbaN.png" alt="enter image description here"></a></p>
  
  <p>I need to print the DLL name as well. Also please advice me how to solve this error. Thanks in advance.</p>