py2exe, python 2.6 and wxPython – hack it #7

If you’ve tried to build a client application with Python 2.6 and wxPython, you might hit a problem.

Python 2.6 no longer includes the Visual Studio dependencies required by wxPython. These dependencies may not be present, either on your build machine, or the target user’s machine.

When building with py2exe, you may encounter an error similar to:

error: MSVCP90.dll: No such file or directory

The solution!

To successfully build your executable, you need the Visual Studio 2008 redistributable package, which can be obtained from Microsoft. Run this on your build machine to install the appropriate DLLs.

If your build still fails, you may need to copy the DLLs into your build directory. Locate msvcp90.dll, msvcm90.dll and msvcr90.dll on your machine and copy them to the build directory.

Once you have a successful Python build, you also want your executable to run on the target machine. To do this, your install script needs to install the vcredist package as part of the installation.

The command you need to run as part of your client installation is:

vcredist_x86.exe /q:a

If you are using NSIS as your installer, the appropriate code is:

File /r vcredist_x86.exe ;to copy the file
ExecWait ‘”$INSTDIR\vcredist_x86.exe” /q:a”‘ ;to install

With the Visual Studio redistributable installed, it will now execute successfully on the target machine. Hurrah!

Leave a Reply