Wednesday, August 26, 2009

Python 2.6, py2exe, and VC++ Runtime Issues

I got this annoying error the other day, while freezing a python 2.6 executable on Windows:

py2exe msvcp90.dll no such file or directory


Python 2.6 uses Visual Studio 2008, and so it requires the Visual Studio 2008 C++ Runtime (vcredist).

I saw a few posts on the web, here and here. They get the solution partially right.

The Correct way to fix py2exe msvcp90.dll no such file or directory.

In your file first exclude the dll so you can build the exe.

options = {
"py2exe": {
"compressed": 1,
"optimize": 2,
"bundle_files": 2,
"dll_excludes": [

Then add this to your manifest file in between the tags:

<assemblyidentity type="win32" name="Microsoft.VC90.CRT" version="9.0.21022.8" processorarchitecture="x86" publickeytoken="1fc8b3b9a1e18e3b"></assemblyidentity>

This allows you to use the vcredist to install the required vc++ dlls on the target system.


Anonymous said...

Hey. Thanks for this post.

If you're distributing a program publically though, I don't think it's feasible to expect end users to run vcredist manually.

Are you only deploying to known environments, or does your program install run vcredist automatically on the client machine?

Thanks for your thoughts.

Rich said...

I run vcredist in the install. So the end user only has to click to run the install, and everything else is done magically behind the scenes.