Problem with wxpython build - 'upgrade needed' message

104 views
Skip to first unread message

Jason Kenney

unread,
Aug 23, 2009, 3:55:19 PM8/23/09
to PyInstaller
Hi,

I'm new to pyinstaller and haven't seen my problem described
elsewhere. I have a project which uses matplotlib with wxpython.
After running through the spec and build process, it seems to end
successfully with the creation of an exe. When I run the file though,
I get a dialog that says:

Window Title: "wxPython Upgrade Needed"

"This application requires a version of wxPython greater than or equal
to 2.8, but a matching version was not found.

You currently have these version(s) installed: (it's blank here)

Would you like to download a new version of wxPython? (Yes/No
buttons)"

I've found that if I manually add wx.pth to the directory with the
exe, the program runs correctly. Is there a way to automate adding
this file? Is this file usually added, and I have a borked install of
some sort, or is path/version info handled differently altogether?

I have fresh installs of the following on Windows XP:
python-2.5.4.msi
matplotlib-0.99.0.win32-py2.5.exe
wxPython2.8-win32-unicode-2.8.10.1-py25.exe
pywin32-214.win32-py2.5.exe

trunk-r701.zip

My build script is:

set PIP=c:\pyinstaller_svn701_2.5\
python %PIP%Makespec.py --onefile --windowed --upx --version
verfile.txt %1%.py
python %PIP%Build.py %1%.spec

Thanks for any help you can give.

Jason

Giovanni Bajo

unread,
Aug 25, 2009, 6:30:21 AM8/25/09
to pyins...@googlegroups.com
On Sun, 23 Aug 2009 12:55:19 -0700 (PDT), Jason Kenney
<jasonk...@gmail.com> wrote:

> I've found that if I manually add wx.pth to the directory with the
> exe, the program runs correctly. Is there a way to automate adding
> this file?

The .spec file is a Python file. You can manually copy the file by adding
some code there, or try using a COLLECT() step which is meant to collect
additional files (see the .spec file generated by Makespec.py --onedir to
see how COLLECT is used). Of course, I'm sure you realize that manually
copying that file is just a workaround, not a fix.

> Is this file usually added, and I have a borked install of
> some sort, or is path/version info handled differently altogether?

No, the file should not be copied. The .pth file is meant to setup the
PYTHONPATH at runtime and it's not useful for a packed executable, since
the correct .pyc files are already bundled within the executable and
there's no need for PYTHONPATH games.

It is possible that wxPython has some custom code that looks for a data
file within its installation directory, something like version.dat or
similar. You will need to look within wxPython code and find the spot where
it does this check. If you can point me to the code, we can study it
together and see if there is a way to disable it for generated executables.
--
Giovanni Bajo
Develer S.r.l.
http://www.develer.com

Jason Kenney

unread,
Aug 25, 2009, 2:32:33 PM8/25/09
to pyins...@googlegroups.com
Thanks for the hints.  I tracked down the error message to wxversion.py (installed in the site-packages dir).  In the preamble, it mentions not to use it when bundling your files for a stand-alone app.  I guess wxPython must use wxversion by default and it looks for wx.pth?  In any event, I added C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wxPython to my PYTHONPATH and now the built exe runs with no problems.

Jason

Giovanni Bajo

unread,
Aug 26, 2009, 9:15:39 AM8/26/09
to pyins...@googlegroups.com

Great. I think we should try adding a hook to avoid this problem to
happen for other people as well.

Can you try adding a hook file to the "hooks" directory called
"hook-wxversion.py", and make it raise a RuntimeError() exception
describing the problem?

Thanks!

Jason Kenney

unread,
Aug 26, 2009, 5:34:29 PM8/26/09
to pyins...@googlegroups.com
I added the hook and found that it gets triggered whether or not PYTHONPATH has the wxPython directory in it.  Here is the full comment from wxversion.py:

"NOTE: If you are making a 'bundle' of your application with a tool
like py2exe then you should *not* use the wxversion module since it
looks at the filesystem for the directories on sys.path, it will fail
in a bundled environment.  Instead you should simply ensure that the
version of wxPython that you want is found by default on the sys.path
when making the bundled version by setting PYTHONPATH.  Then that
version will be included in your bundle and your app will work as
expected.  Py2exe and the others usually have a way to tell at runtime
if they are running from a bundle or running raw, so you can check
that and only use wxversion if needed.  For example, for py2exe::

    if not hasattr(sys, 'frozen'):
        import wxversion
        wxversion.select('2.5')
    import wx

More documentation on wxversion and multi-version installs can be
found at: http://wiki.wxpython.org/index.cgi/MultiVersionInstalls"

The applicable section from that link is at http://wiki.wxpython.org/index.cgi/MultiVersionInstalls#head-39f9ba136f6882f69af127cb8ebf5551ddf9a208

Maybe there's another way to handle the hook to implement their suggestions?  I'm getting a bit out of my depth here :)

Jason

Florian Höch

unread,
Aug 26, 2009, 7:19:39 PM8/26/09
to pyins...@googlegroups.com
Actually, this whole thing is a matplotlib and not a wxpython issue,
because they are not using the hasattr(sys, 'frozen') conditional in
their wx backend when importing wxversion
(matplotlib\backends\backen_wx.py, line 114).

Regards,

Florian Höch

Jason Kenney schrieb:
Reply all
Reply to author
Forward
0 new messages