-2

This is my first time using wxPython Python can go theatre my code

import wx
app=wx.App()
win=wx.Frame(None, -1, 'Window Title')
win.Show()
app.MainLoop()

This is the Error i'm getting:

Traceback (most recent call last):
  File "C:/Users/sancios/Desktop/huluhup", line 1, in <module>
    import wx
  File "C:\Python27\lib\site-packages\wx-3.0-msw\wx\__init__.py", line 45, in <module>
    from wx._core import *
  File "C:\Python27\lib\site-packages\wx-3.0-msw\wx\_core.py", line 4, in <module>
    import _core_
ImportError: DLL load failed: %1 is not a valid Win32 application.
Joran Beasley
  • 110,522
  • 12
  • 160
  • 179
sancios
  • 7
  • 5
  • 1
    Please use a more informative title. – Raman Shah Feb 12 '14 at 23:04
  • What would you like to happen in the line `win=wx.Frame(None, -1 'Window Title')` ? In particular, what is the `-1` for, and how is it supposed to sit there in front of a string `'Window Title'`? – Floris Feb 12 '14 at 23:06
  • @Floris its standard wx class instantiation `Frame(parent,id,window_title)` -1 means use default and calculate the id – Joran Beasley Feb 12 '14 at 23:07
  • @sancios how did you install wx? make sure you use the same bits as your python (64 if 64 bit python, 32 if 32bit python) – Joran Beasley Feb 12 '14 at 23:08
  • 1
    @JoranBeasley in that case is there a comma missing? `wx.Frame(None, -1, 'Window Title')`? – Floris Feb 12 '14 at 23:08
  • ahh good catch ... but his error is on the `import wx` line ... im guessing he installed wx for the wrong python version or something – Joran Beasley Feb 12 '14 at 23:09
  • @Floris nice find, but this is a syntax error. Obviously, the interpreter doesn't even reach that line and crashes on the import. – Cilyan Feb 12 '14 at 23:10
  • @sancios you could simplify the python code to simply `import wx` ... there is a problem with your wx install I think – Joran Beasley Feb 12 '14 at 23:11
  • 2
    possible duplicate of [DLL load failed: 1% is not valid win32 application](http://stackoverflow.com/questions/9277875/dll-load-failed-1-is-not-valid-win32-application) – Cilyan Feb 12 '14 at 23:15
  • @Cilyan - you are right, this is an exact duplicate. – Floris Feb 12 '14 at 23:19

1 Answers1

0

It sounds like you are mixing Python and wxPython versions. They must match. For example, if I have Python 2.7 32-bit, then I need a wxPython 3.0 32-bit for Python 2.7. You cannot install a wxPython that is 64-bit with a Python 32-bit (or vice versa) and expect it to work.

Mike Driscoll
  • 32,629
  • 8
  • 45
  • 88