How do I resolve Python ImportError when using a Python Extension Module in a Debug configuration?

Caleb 1 Reputation point
2021-06-17T19:39:12.793+00:00

I am trying to run a "Python Application" template project that uses a "Python Extension Module" template project. I am using the default configuration settings for these projects. Everything works great in a Release configuration, but the Debug configuration is giving me errors. When I run the python application, I get the following error:

ImportError('DLL load failed: The specified module could not be found.')

The exact steps I am taking for this are as follows:

  1. Create a new solution.
  2. Add a new "Python Extension Module" project from the templates list, named "module1".
  3. Add a new "Python Application" project from the templates list, named "PythonApplication1".
  4. Add a reference to "module1" from "PythonApplication1".
  5. In the file "PythonApplication1.py", add the line "import module1". For the Debug configuration, it appears this should be "import module1_d", which I have also tried.
  6. Build the solution.
  7. Set "PythonApplication1" to be the startup project and "PythonApplication1.py" to be the startup file.
  8. Start debugging.

As I said above, these steps work perfectly for a Release configuration and there is no error, but for a Debug configuration it errors out. My goal is to have the full capabilities of the IDE for debugging that a Debug configuration typically provides for C/C++ code, so I would love to get some help for this issue.

Developer technologies Visual Studio Debugging
Developer technologies Visual Studio Other
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.