rayantony / torchat

Automatically exported from code.google.com/p/torchat
0 stars 0 forks source link

Can't import wx when wxWidgets and wxPython are version 2.9 #78

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Install wxWidgets 2.9.1
2. Install wxPythong 2.9.1.1
3. run python torchat.py

What is the expected output? What do you see instead?
I expect it to work. Instead it fails to import wx

What version of the product are you using? On what operating system?
I'm using the source from 2011-01-13 on Mac OS X 10.5.8.

Please provide any additional information below.
Changing wxversion.select('2.8') to wxversion.select('2.9') fixes the problem.

A better fix is probably to do something like (not actually tested)
try:
    wxversion.select('2.9')
    import wx
except:
    wxversion.select('2.8')
    import wx

I'm not sure what the comment in the except block is saying, so it's quite 
possible this doesn't work like I think it would.

Original issue reported on code.google.com by schecko...@gmail.com on 14 Jan 2011 at 1:42

GoogleCodeExporter commented 9 years ago
the comment says that wxversion will not work in the frozen binary that is 
created with pyinstaller, it throws an exception, so if wxversion fails then i 
assume that it is the frozen windows binary and it should use the wx that 
happens to be available. In all other cases it should use 2.8 

I intentionally base it on wxpython 2.8 because i can't test it with newer 
versions here. I am developing on an old Ubuntu Hardy which has python 2.5 and 
wx 2.8 you can install wxpython 2.8 without making it the default wx 
installation.

Original comment by prof7...@gmail.com on 14 Jan 2011 at 2:45

GoogleCodeExporter commented 9 years ago
wxWidgets and wxPython in MacPorts are not in a very good state. Multiple 
versions do not really coexist well. The native UI support in 2.9 is far 
superior to that in 2.8.

Original comment by schecko...@gmail.com on 14 Jan 2011 at 3:07

GoogleCodeExporter commented 9 years ago
i see. I wasn't thinking about Mac. These lines were a crude hack to make it 
try to use 2.8 if available and the default wx otherwise but I also didn't 
really test it. If it worked as intended it *should* have used 2.9 on your 
system already but I think I should have another look at the documentation for 
wxversion to do this correctly.

The intended logic should have been (but I did it wrong): if it can find 2.8 
then use 2.8 and otherwise just use the default version. I will have to look at 
the code again. This should be fairly simple.

You made a lot of patches, I am glad that finally somebody else is looking at 
the code and trying to help me with actual patches. I hope that I will find the 
time during the weekend to go over it and incorporate all your patches (I have 
only limited resources and not much uninterrupted time during the week until 
late friday evenig).

Original comment by prof7...@gmail.com on 14 Jan 2011 at 9:17

GoogleCodeExporter commented 9 years ago
currently it does the following:

import wxversion
try:
    wxversion.select('2.8')
except:
    # continue anyways. 
    # the pyinstaller binary has problems with wxversion's 
    # way of searching though the (non-existing) directories.
    # so just try to use the wx version that is there.
    pass

import wx

if you have wx 2.9 and not 2.8 then I would expect the select() method to throw 
an exception (which will be ingnored) and the the import wx will import 
whatever is your default version (2.9). This should not produce any further 
errors and just work.

What exactly is happening and why does a simple

import wx

not simply import wx 2.9 (which should be yout only and default wx)? What 
errors are you getting?

Original comment by prof7...@gmail.com on 15 Jan 2011 at 10:04

GoogleCodeExporter commented 9 years ago
[mb:~] steve$ python
Python 2.7.1 (r271:86832, Jan 13 2011, 17:53:35) 
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import wxversion
>>> try:
...     wxversion.select('2.8')
... except:
...     pass
... 
>>> import wx
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named wx
>>> 
[mb:~] steve$ python
Python 2.7.1 (r271:86832, Jan 13 2011, 17:53:35) 
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
>>> 

The wxversion.select('2.8') is throwing an exception. If, after the try/except 
block in the first one, I use wxversion.select('2.9') then the import wx 
succeeds.

Perhaps the best fix is to use

import wxversion
if wxversion.checkInstalled('2.8'):
    wxversion.select('2.8')

Original comment by schecko...@gmail.com on 15 Jan 2011 at 10:27

GoogleCodeExporter commented 9 years ago
Oops, that should be

import wxversion
if wxversion.checkInstalled('2.8'):
    wxversion.select('2.8')
import wx

Original comment by schecko...@gmail.com on 15 Jan 2011 at 10:29

GoogleCodeExporter commented 9 years ago
can you check out the latest svn (or svn up your working copy) and try whether 
the wx import now works? Also with enabled logging to catch errors during 
import? 

Original comment by prof7...@gmail.com on 15 Jan 2011 at 11:21

GoogleCodeExporter commented 9 years ago
I have now decided to make all Mac related tweaks and optimizations with 2.9 
and recommend 2.9 on Mac but stick with 2.8 on all other platforms, at least 
for now (never change a running system)

Original comment by prof7...@gmail.com on 15 Jan 2011 at 11:24

GoogleCodeExporter commented 9 years ago
That works for me!

Original comment by schecko...@gmail.com on 15 Jan 2011 at 11:51

GoogleCodeExporter commented 9 years ago
ok, then i can move on to your next patch, marking this one as fixed.

Original comment by prof7...@gmail.com on 16 Jan 2011 at 12:24