pywin32 Extensions and Movable Python
Using the pywin32 Extensions
The pywin32 extensions  present a particular challenge for use with Movable Python. This is because they detect the presence of sys.frozen and behave differently when working in a frozen environment. Unfortunately this fix doesn't work when used with Movable Python.
A lot of the work of getting this extension to function has already been done for you. However there is one more thing you may need to do.
If you have difficulties with the Python windows extensions then try adding the following line to the start of your code :
temp = sys.frozen del sys.frozen import win32api sys.frozen = temp del temp
This leaves sys.frozen in place after the import has taken place.
This solution was discovered by Brian Beck who created a utility called fix_shortcuts.py, for use with Movable Python.
A summary of his efforts is included below, in case it is useful for any other extensions that do similar magic.
A Movable Python user, Brian Beck, has been working on a small program that allows you to keep shortcuts to applications on a flash card, along with Movable Python. His program fix_shortcuts.py is currently located at http://exogen.case.edu/code/fix_shortcuts.py. Because windows shortcuts must contain an absolute path, they need to be edited every time the drive letter changes. With portable flash devices it is likely that the drive letter will change on every machine they are plugged into. fix_shortcuts.py uses the pywin32 extensions, by Mark Hammond, to change the location pointed to by the shortcuts. Most libraries can be used just by copying the whole package from 'site-packages' into the 'lib/' directory. This approach didn't work with pywin32, due to a peculiarity with pywin32. (Note this problem might also affect other libraries that dynamically adjust their __path__ attribute, or use sys.frozen to do any other magic).
A summary of the technique needed to make it work :
For an explanation of why this was necessary, read the following description from Brian.
First off it should be noted that pywin32 makes the following directories in a normal distribution's site-packages directory:
It also adds a few files to the root of site-packages (pythoncom.py, PyWin32.chm, pywin32.pth).
After moving the above files & directories to the appropriate location in Movable Python (into the 'lib/' directory), I added the paths in pywin32.pth to Movable Python's syspaths.pth.
Now, it won't let me import pythoncom just yet -- it complains that 'pythoncom isn't in frozen sys.path.' Moving pythoncom24.dll from the pywin32_system32 directory to MovPy's root lib directory (to join the existing pywintypes24.dll) fixes this. Now it's okay to get rid of the pywin32_system32 directory (so it seems).
Now I can import pythoncom and win32com -- but this is where the trouble starts! win32com itself has modules such as shell, ifilter, internet, and mapi to name a few. Instead of keeping these in its own (win32com) directory, it puts them in the separate win32comext directory. To find out about this separate directory, it seems to consult the registry. As I said, I can import win32com, but trying to import, for example, win32com.shell fails (no module named shell).
I find this (that it fails) odd because after looking at the code, it looks like after failing to find the appropriate registry key it defaults to the 'win32comext' directory, so shouldn't it find 'shell'? Also, I do actually have the entries in my registry because I have pywin32 installed (and working) on my standard Python distribution. So even if the paths stored in the registry are absolute instead of relative, it should be able to load the win32com extensions.
However it doesn't find it. The reason for this is that pywin32 knows about sys.frozen. If an application is frozen (using py2exe) it expects a different directory structure to a normal python distribution. With Movable Python we had basically copied the directory structure straight from site-packages. Now we still need to make the above changes (moving the dlls, adding the relevant lines to syspaths.pth), but we also need to tell pywin32 that the script wasn't built using py2exe. This means that we need to add the line del sys.frozen to our script before importing anything from pywin32. A convenient place to do this might be in the customize.py file.
So why don't we just delete the sys.frozen attribute by default ? Well... the rub is that if Movable Python is built with the pywin32 extensions included, then they will need sys.frozen. For this reason it seems better to leave things as they are. It is possible that this problem might affect other modules as well. If you have problems importing from a module you have added into the 'lib/' directory, then try adding del sys.frozen to your script and see if this makes any difference.
A user (Jim C) has also reported a problem with using win32api.
import win32api was failing with an ImportError: DLL load failed message.
After a bit of digging around he discovered that the problem was due to a conflict with pythoncom24.dll and pywintypes24.dll installed in the Windows/System32 directory.
The solution (from here) is simple. If you do these imports (and in this order) the problem goes away.
Please note the additional instructions on using the extensions with py2exe/Movable Python.
From : http://starship.python.net/crew/mhammond/win32/ (dlls available for download here)
To run Pythonwin, you may need a copy of the Microsoft MFC DLLs. You should only install these files if the install process tells you the DLL can not be found, or if Pythonwin fails to start due to this DLL missing.
Download these files and save them to your Windows System32 directory. Alternatively in the same directory as the script being run or elsewhere in windows PATH (not sys.path !).