0

I have a python script that works fine on my computer (Python 2.7 32 bit installed). It has the following imports :


    import mechanize
    from bs4 import BeautifulSoup
    from Tkinter import *
    import json
    import webbrowser

I wanted to distribute this to others so I found that we can create exe files using py2exe. I wrote a script like this:


    from distutils.core import setup
    import py2exe

    setup(console=['notification.py'],
        options = {'py2exe' : {
            'packages' : ['bs4', 'mechanize','Tkinter', 'json', 'webbrowser']
        }})

This works fine on my computer but when I run it on Windows XP, I get this error -


    Traceback (most recent call last):
      File "notification.py", line 3, in 
      File "Tkinter.pyc", line 38, in 
      File "FixTk.pyc", line 65, in 
      File "_tkinter.pyc", line 12, in 
      File "_tkinter.pyc", line 10, in __load
    ImportError: DLL load failed: %1 is not a valid Win32 application.

I tried searching other threads but found none that has the same problem. So please help me fix this issue.

user3215014
  • 147
  • 2
  • 2
  • 11

2 Answers2

1

Maybe Tinkiter is a 64 bit version GUI, while Windows XP version you run it is 32bit.

Check it out and tell us if that's the case.

Reason I assume this is the line:

ImportError: DLL load failed: %1 is not a valid Win32 application.

combined with the fact that Tinkiter is 64 bit.

Python can be 32 bit. Works on both Operating Systems, 32 and 64 bit ones. But Tinkiter is a GUI, something different than the language. So Including a 64bit add-on, into a 32bit application... can cause some trouble. :)

Suggestion: You can start by making the app work in console interface if possible. Then you can use another GUI that can run in 32 bit.

For instance, you can get a 32bit version of THIS

Edit: Added a suggeston.

George Eco
  • 466
  • 3
  • 16
  • I will have to make a lot of changes in my code in case I have to use some other GUI application. And yes my xp is a 32 bit system. Is there some other fix? which can work on both windows and linux ? Like making some other type of standalone ? – user3215014 Aug 18 '14 at 17:19
  • Well it is not about Linux and Windows issue really. It is about 32bit version of your GUI and 64bit version of it. If Linux or Windows is 32 bit, you MUST use 32 bit software. If it is BOTH 64 bit it will be all right. I am not sure about it but is there a 32bit version of Tkinter? If yes, you should use that version to build your application with less editing. – George Eco Aug 18 '14 at 17:33
  • Can not comment under your answer yet, due to reputation restriction. So I solved your case right? It was about installed 32bit with 64bit components. – George Eco Aug 19 '14 at 10:45
  • Actually it was because of having 2 versions of python installed and not the version of Tkinter issue. Still I will upvote yours becaue it pointed me to the right direction. Thank you :) – user3215014 Aug 19 '14 at 12:04
  • Oh you had two Python versions! So case solved. Glad to hear that. :) Cheers mate. – George Eco Aug 19 '14 at 12:35
1

Well, I had installed both versions of Python 32 bit and 64 bit in my machine. When I was making it a stand alone probably some dlls were copied from the wrong library. So I completely uninstalled both versions and then installed 32 bit and it worked fine.

user3215014
  • 147
  • 2
  • 2
  • 11