0

I'm trying to compile a Python project (using Python 2.7 on Windows XP) into an EXE using PyInstaller with the default options. When I try to run the EXE, I get the message:

PyInstaller - ImportError: No module named win32api

I added the win32api path to the windows PATH environment variable (I do have Python Win32 Extensions installed) but it's not working. I'm pretty new to this and a little overwhelmed by all the options etc, and I really have no idea where to start (or what information would be useful to solving this problem.) I assume this is some little thing that I'm missing, but I haven't found anyone having precisely this problem online and any help would be greatly appreciated.

DivideByZer0
  • 745
  • 8
  • 26
  • 1
    Which version of PyInstaller are you using? – Luke Woodward Jul 10 '12 at 20:57
  • PyInstaller -v returns "2.0dev-". I downloaded the most recent development version today, as the site said the current version has too many bugs for Windows/OSX? – DivideByZer0 Jul 10 '12 at 21:01
  • Just tried the previous version of PyInstaller, and I'm getting the same error. – DivideByZer0 Jul 10 '12 at 21:09
  • 1
    Odd - I admit I've not seen this error myself, so all I can really do is guess. I'm still using v1.5.1 myself as I had a quick play with the 2.0-dev version and couldn't get it to work. What dependences (such as wxPython, PyQt, Tkinter, django, etc., if any at all) are you using with your Python project? Can you use pyinstaller to build an executable that just prints "hello world"? If you can, try cutting out bits of your project and rebuilding the executable to see if the error remains. Perhaps that will help you narrow down what's causing the problem. – Luke Woodward Jul 10 '12 at 21:26
  • Hmm, thanks for looking into it. I'll give that a try; my project is using PyQt throughout (which would be nigh impossible to remove), as well as a library for a USB data acquisition board, a lot of serial communication stuff, as well as OpenCV. My guess is that it would be PyQt or OpenCV that are causing it, but I'll try throwing something basic together and see if that works. – DivideByZer0 Jul 10 '12 at 22:05
  • Okay, Hello World is looking okay, let me see if I can get away with importing/instantiating some of the classes from this program. – DivideByZer0 Jul 10 '12 at 22:08
  • Okay, time for me to leave work here, but I'm in the process of narrowing it down! (it's a little tricky because half these classes are importing each other, but I'm getting to the bottom of it.) I'll let you know tomorrow once I figure out which module is causing this! – DivideByZer0 Jul 10 '12 at 22:59
  • So, it turns out that this is being caused by the statement "import OS", as in one of the classes the program name is assigned with the lines: 'import os' '__progname__ = os.path.basename(sys.argv[0])' Since that's pretty inconsequential, I commented them out for now, but it appears to the the "os" module that was causing this. Now I'm getting an issue with some C imaging library, but it looks like this is resolved for now...Thanks for your help! – DivideByZer0 Jul 11 '12 at 17:27

1 Answers1

1

Ok, it looks like "import os" in one of my modules was causing this issue. I had no luck getting it to successfully use the win32api module, but since this was only being used to set the program name, I just commented this out and this particular issue is resolved. Thanks Luke for your help!

DivideByZer0
  • 745
  • 8
  • 26