[GRASS-dev] Re: problem with CheckForWx in wxGUI

Martin Landa landa.martin at gmail.com
Sun Jul 27 04:18:59 EDT 2008


Hi,

2008/7/27 Michael Barton <michael.barton at asu.edu>:

[...]

>    try:
>        import wxversion
>        wxversion.select(str(majorVersion))
>        import wx
>
> The problem lies in wxversion.select. It is looking for the SOURCE CODE
> files in a BINARY wxPython installation. They simply are not there. Here is
> what happens if I run this in the Python interpreter.
>
>>>> import wx
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
>  File
> "//Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/wx-2.8-mac-unicode/wx/__init__.py",
> line 45, in <module>
>  File
> "//Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/wx-2.8-mac-unicode/wx/_core.py",
> line 4, in <module>
> ImportError: No module named _core_
>>>>
>
> Note, it is checking for _core.py.
> I have _core.pyo and _core.pyc, but not the source _core.py. I don't have
> any source files in this binary installation. It works fine and takes up
> less space I suppose. But this sequence ...
>
> import wxversion
> wxversion.select(str(majorVersion))
> import wx
>
> ...fails not because I have the wrong version, but because I do not have the
> SOURCE files that it uses to check for the version. This is a bug in
> wxversion. It should be looking for _core.*, not a specific source file
> _core.py. If I disable version checking by putting a return at the beginning
> of CheckForWx(), wxgui loads and runs fine. But we should have a version
> check (though I don't know if we need to check it in so many modules; at
> startup should be enough.
>
> The following code works fine.
>
> def CheckForWx():
>    """Try to import wx module and check its version"""
>
>    majorVersion = 2.8
>    minorVersion = 1.1
>
>    try:
>        #import wxversion
>        #wxversion.select(str(majorVersion))
>        import wx
>        version = wx.version().split(' ')[0]
>        if float(version[:3]) < majorVersion:
>            raise ValueError('You are using wxPython version %s' %
> str(version))
>        if float(version[:3]) == 2.8 and \
>                float(version[4:]) < minorVersion:
>            raise ValueError('You are using wxPython version %s' %
> str(version))
>
> This checks to make sure that the default wxpython installation is 2.8.1.1
> or higher. If not, it throws an error and does not load wxgui.

Michael, I can just repeat what I said, wxPython ML is right place
where to ask how to solve this problem. Calling wxversion.select() is
important here since you can have 2.6 and 2.8 installed on your
computer. At least on Debian it's quite likely...

Martin

-- 
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa *


More information about the grass-dev mailing list