2

I am trying to create a installer with pynsist for my python application, which uses PyQt4. I want to bundle the python installation, therefore, I have to use python 3.5, as pynsist supports bundling only for python 3.5. I used a fresh WinPython 3.5.1.1 installation where I installed all the necessary packages and test the installer in a freshly installed Windows 10 virtual box. For building the installer I use the WinPython 3.5.1.1 environment on my Windows 7 machine.

But when I start the installed application, I get an error when QtGui or QtCore is imported:

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

Most problems with this error I found in the internet are caused by python not being able to find the dll, but the QtGui4.dll file is present in the pkgs\PyQt4 folder and also copying it to the main folder of the application or the python folder doesn't change anything.

I also tried to export the example PyQt4 application in the pynsist repository with bundling and python 3.5.1 as a minimal example, but I get the same error.

Using the dependency walker in the Windows 10 environment on QtCore.pyd yield: enter image description here There are a lot more "API-MS-WIN*.DLL" dependencies missing, I just scrolled to the part where it seamed to be most "interesting".

Randrian
  • 1,055
  • 12
  • 25
  • You may be able to use [dependency walker](http://www.dependencywalker.com/) to find what DLLs are missing, though the site appears to be down at the moment. I'll try to build the PyQt4 example with Python 3.5 at some point today and see if it works. – Thomas K Jan 12 '16 at 10:05
  • I successfully built the PyQt example with Python 3.5.1, using PyQt extracted from a wheel on Christoph Gohlke's site. You can test [the installer](https://www.dropbox.com/s/iem1wix8z2u6b9l/List_App_%28PyQt%29_1.0.exe?dl=0) (which could probably be made a bit smaller and faster by eliminating extraneous files). It worked for me on my Windows 8 installation. I suspect that WinPython's copy of PyQt might rely on some files installed elsewhere in the environment, whereas the wheel appears to be self contained. – Thomas K Jan 12 '16 at 11:45
  • Thank you for your effort. I tired to use your installer and i get the same error. To display the error I use a bat file which starts the script with a console window and a 'pause' command. Did you get a window that is opened or just a console that closes instantly? Perhaps it just doesn't work with Windows 10. – Randrian Jan 12 '16 at 15:33
  • The same problem also occurs when I build an installer with python 3.5 without bundling. So it should be a problem between python 3.5, windows 10 and pynsist. And I added the output of the dependency walker under Win10 to the question post. – Randrian Jan 12 '16 at 16:20
  • Can you look at the tree view (it appears in the top left of dependency walker for me). That list shows you everything it failed to find working recursively, and I see several things in there as well, even though it worked. It's probably the top level of things that matter the most. And it won't find VCRUNTIME140 or PYTHON35 statically, but they'll be loaded because they're next to the Python exe. – Thomas K Jan 12 '16 at 17:39

1 Answers1

1

The missing dll file is msvcp140.dll.

This file can be included in the installation by putting this file into the pynsist_pkgs directory next to the .cfg file.

To load it on runtime the pkgs has to be added to path. This can be done using an extra_preamble file containing:

os.environ['PATH'] = pkgdir + os.pathsep + os.environ.get('PATH', '')
Randrian
  • 1,055
  • 12
  • 25
  • That's annoying - it shouldn't be necessary to do those extra steps. After a bit of fiddling, I now see it on Windows 8 too; the problem was masked by something else I had installed. – Thomas K Jan 14 '16 at 11:44
  • I have [opened an issue](https://github.com/takluyver/pynsist/issues/58) to try to iron out what's needed. In the meantime, I think you may be able to remove the need for extra_preamble by putting `msvcp140.dll` inside the `PyQt4` folder - I think DLLs are automatically found in the folder where the DLL loading them lives. – Thomas K Jan 14 '16 at 12:07
  • It turns out this is what you need to do, though I was right that putting it inside the PyQt4 folder removes the need for extra_preamble. I've added a note to the [PyQt4 example](https://github.com/takluyver/pynsist/tree/master/examples/pyqt) README. – Thomas K Jan 21 '16 at 16:21