Python, COM and windows 8

Recently I got myself a new laptop which came pre-installed with windows 8. Rather than instantly wiping it out and installing windows 7, I decided to give it a try.

After getting over the initial shock, I installed all my usual python tools and started setting up my scripts... only to suddenly be stopped dead in my tracks when all my comtypes related scripts no longer worked, coming up with something along the lines of:

                 TypeError: '_Dispatch' object is not callable

Lame! Anyway, if anyone else encounters this, the solution turned out to be running the Python command line in XP compatibility mode.

To set this up in windows 8, you can follow these steps:

  1. Go to your control panel.
  2. Click on the 'Programs' category. 
  3. Click on 'Run programs made for previous versions of windows'
  4. Step through the troubleshooter, selecting your Python command line as the target program. 
And it should all work again! 

2 comments:

  1. Did COM change in windows 8? I remember someone mentioning MS was no longer supporting it, but that is entirely hearsay. But this post reminded me of that. So maybe something changed in the way they are doing things now and just support it with this workaround for now?

    ReplyDelete
    Replies
    1. Ha, its all hearsay from my end too! To be honest, I'm not sure exactly what changed under the hood and only got as far into it as my work around!

      I haven't really been able to find too much information on changes, but one article mentions that the 'Metro' SDK still contains a subset of the traditional win32, COM and .NET framework APIs so I can't imagine them being removed entirely any time soon.

      http://kishore1021.wordpress.com/2012/01/14/part-3-introduction-to-winrt-the-new-windows-runtime-in-windows-8/

      Delete

Comments?