Re: [Tutor] where does the ViewerFrameWorkGUI come from

2011-12-18 Thread Steven D'Aprano

lina wrote:

Hi,

I met below issue:

File /usr/lib/python2.7/dist-packages/ViewerFramework/VF.py, line
369, in __init__
self.GUI = ViewerFrameworkGUI(self, title=title,
NameError: global name 'ViewerFrameworkGUI' is not defined


Is VF.py your code?

If so, you have a bug in the code.

If not, then *possibly* there is a bug in the ViewerFramework package. Or more 
likely you are aren't using it correctly. My guess is that you haven't 
initialised the framework correctly. Read the documentation for it.




can someone tell me how to examine,

I mean, how to examine, what would you do when you face the problem?


Read the documentation.
Check your code.
Google for the error message and see if other people are having it.
What are you doing that leads to the error? Do something different.
If there is a forum specifically for the ViewerFramework package, ask there.
If not, write to the author.



--
Steven

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] where does the ViewerFrameWorkGUI come from

2011-12-18 Thread Walter Prins
Lina,

On 18 December 2011 05:08, lina lina.lastn...@gmail.com wrote:
 Hi,

 I met below issue:

 File /usr/lib/python2.7/dist-packages/ViewerFramework/VF.py, line
 369, in __init__
    self.GUI = ViewerFrameworkGUI(self, title=title,
 NameError: global name 'ViewerFrameworkGUI' is not defined


 can someone tell me how to examine,

 I mean, how to examine, what would you do when you face the problem?

You should be telling us what you're doing, what platform you're
using, what packages you've installed and so on, and not be leaving us
to guess these things.  It makes our job harder than it would
otherwise be.  That said, I've spent only a few minutes to
troubleshoot this and will outline what I did so you can see what I
did when faced with this problem:

1.) Some googling reveals to me that ViewerFramework/VF.py apparently
forms part of a molecular visualization package called
mgltools-viewerframework.
2.) OK so Installing this package yields the same files in the same
location on my Ubuntu 11.10 box.
3.) Trying to see what was going on, I then when on to inspect the
referenced source file at line 369, where it becomes apparent that the
code is trying instantiate a class ViewerFrameworkGUI.
4.) The question then occurs: Where does this class come from?  How is
it that it's not defined?  Consequently I started searching for this
class, firstly in the same file, so see where it may be defined or
where it might be imported from.
5.) Doing so I found the following code at line 221 in VF.py:
try:
from ViewerFramework.VFGUI import ViewerFrameworkGUI
except:
pass

Curious, I thought, how is it that this module can fail to import
this class?  And why is it squashing the exception?  Generally I would
consider this type of behaviour very undersireable.  Far better would
be to stub or mock out the class with a fake that gives some useful
behaviour if it's instantiated (e.g. even if just to give some
sensible error message to the end user...) but perhaps this is a
semi-standard way of stubbing out optional extensions to packages in
Python.

6.) So next I decided to manually replicate the aboev import in the
Python interpreter to see what would happen:
walterp@s1:/usr/lib/python2.7/dist-packages/ViewerFramework$ python
Python 2.7.2+ (default, Oct  4 2011, 20:06:09)
[GCC 4.6.1] on linux2
Type help, copyright, credits or license for more information.
 from ViewerFramework.VFGUI import ViewerFrameworkGUI
Traceback (most recent call last):
  File stdin, line 1, in module
  File /usr/lib/python2.7/dist-packages/ViewerFramework/VFGUI.py,
line 21, in module
import Tkinter, thread, string, Pmw, types
ImportError: No module named Pmw


Well then, what's this 'Pmw' that's missing? I thought to myself.  A
quick google later and I found it: http://pmw.sourceforge.net/

7.) OK, so that import will fail with an exception due to Pmw being
missing (if it's not installed), but it'll go unnoticed due to the
exception handler squashing it.  This however means that the
ViewerFrameworkGUI class is not always defined, which will cause other
stuff depending on it to fail mysteriously (as you've found.)  At this
point, not knowing anything about the packages involved, I'd
tentatively suggest that perhaps the Pmw package should be a
dependency of the mgltools-viewerframework, and it not being might be
an omission/bug in the package.  Then again maybe they deliberately
don't want the mgltools-viewerframework package to be neccesarily
dependant on the Pmw package but keep it optional.  Whatever the case
is, the bottom line is that you need it in order to solve this
issue...

8.) Knowing that oftentimes python modules are packaged on Debian
based systems (like Ubuntu) as python-xxx I then tried:
sudo apt-get install python-pmw
... and voila, the Pmw module should now be there.

9.) Thus I retried my experiment to manually import ViewerFrameworkGUI
as before:
walterp@s1:/usr/lib/python2.7/dist-packages/ViewerFramework$ python
Python 2.7.2+ (default, Oct  4 2011, 20:06:09)
[GCC 4.6.1] on linux2
Type help, copyright, credits or license for more information.
 from ViewerFramework.VFGUI import ViewerFrameworkGUI
Traceback (most recent call last):
  File stdin, line 1, in module
  File /usr/lib/python2.7/dist-packages/ViewerFramework/VFGUI.py,
line 22, in module
from PIL import Image, ImageTk
ImportError: cannot import name ImageTk

Hmmm, so now it's not finding the ImageTk class from the PIL library
for some reason I thought.  Why might that be...?  I checked and I
did in fact have the PIL library already installed, so it wasn't that
PIL wasn't there at all.  (This should've been expected since if PIL
wasn't there at all, then presulably importing Image would've also
failed...)

A little bit of further googling and I find some evidence that ImageTk
was (for whatever reason) seperated into its own package with the
advent of Python 2.6 (See
http://www.python-forum.org/pythonforum/viewtopic.php?f=4p=65248 and

Re: [Tutor] where does the ViewerFrameWorkGUI come from

2011-12-18 Thread lina
On Mon, Dec 19, 2011 at 4:28 AM, Walter Prins wpr...@gmail.com wrote:
 Lina,

Hi Walter,

I am sorry, before I posted I did not realize people would get much
attention to do all following as you did.

Thanks,

Well, yesterday I posted a bug report and later during my waiting,
based on it's also python related, so I was interested in digging
further, googled showed me uninstall python 2.6 and re-install
autodocktools will solve this problem (but later checked, it's not a
sound/logical way of solving this problem, might with my
luck/careless, during this process, something was fixed)

before uninstall python2.6,
the VF.py, well, when I tried to grep ViewerFrameworkGUI, it shows no
results, but used ViewerFramework,

after I removal of python2.6, during re-installation of autodocktools,
the relevant depedence package (), in the situation without 2.6,

I checked the VF.py, now it has the ViewerFrameworkGUI, not ViewerFramework.
and then I installed 2.6,

as you can see in my box, both
/usr/lib/python2.7/dist-packages/ViewerFramework/VF.py
/usr/lib/python2.6/dist-packages/ViewerFramework/VF.py

all symbolic links to
/usr/share/pyshared/ViewerFramework/VF.py

I still don't understand what's going on.

and it's pretty weird, before I cat VF.py | grep  ViewerFrameworkGUI,
it showed no result, but now it has.

and most weird is that I noticed the
-rw-r--r-- 1 root root  62177 Aug 18 06:38 VF.py

it's been month ago, seems nothing changed.

even yesterday I also remove and re-install the mgltools-viewerframework.
2011-12-18 13:15:06 remove mgltools-viewerframework
1.5.6~rc2+cvs.20110926-1 none
2011-12-18 13:56:00 install mgltools-viewerframework none
1.5.6~rc2+cvs.20110926-1

Thanks with best regards,




 On 18 December 2011 05:08, lina lina.lastn...@gmail.com wrote:
 Hi,

 I met below issue:

 File /usr/lib/python2.7/dist-packages/ViewerFramework/VF.py, line
 369, in __init__
    self.GUI = ViewerFrameworkGUI(self, title=title,
 NameError: global name 'ViewerFrameworkGUI' is not defined


 can someone tell me how to examine,

 I mean, how to examine, what would you do when you face the problem?

 You should be telling us what you're doing, what platform you're
 using, what packages you've installed and so on, and not be leaving us
 to guess these things.  It makes our job harder than it would
 otherwise be.  That said, I've spent only a few minutes to
 troubleshoot this and will outline what I did so you can see what I
 did when faced with this problem:

 1.) Some googling reveals to me that ViewerFramework/VF.py apparently
 forms part of a molecular visualization package called
 mgltools-viewerframework.
 2.) OK so Installing this package yields the same files in the same
 location on my Ubuntu 11.10 box.
 3.) Trying to see what was going on, I then when on to inspect the
 referenced source file at line 369, where it becomes apparent that the
 code is trying instantiate a class ViewerFrameworkGUI.
 4.) The question then occurs: Where does this class come from?  How is
 it that it's not defined?  Consequently I started searching for this
 class, firstly in the same file, so see where it may be defined or
 where it might be imported from.
 5.) Doing so I found the following code at line 221 in VF.py:
 try:
    from ViewerFramework.VFGUI import ViewerFrameworkGUI
 except:
    pass

 Curious, I thought, how is it that this module can fail to import
 this class?  And why is it squashing the exception?  Generally I would
 consider this type of behaviour very undersireable.  Far better would
 be to stub or mock out the class with a fake that gives some useful
 behaviour if it's instantiated (e.g. even if just to give some
 sensible error message to the end user...) but perhaps this is a
 semi-standard way of stubbing out optional extensions to packages in
 Python.

 6.) So next I decided to manually replicate the aboev import in the
 Python interpreter to see what would happen:
 walterp@s1:/usr/lib/python2.7/dist-packages/ViewerFramework$ python
 Python 2.7.2+ (default, Oct  4 2011, 20:06:09)
 [GCC 4.6.1] on linux2
 Type help, copyright, credits or license for more information.
 from ViewerFramework.VFGUI import ViewerFrameworkGUI
 Traceback (most recent call last):
  File stdin, line 1, in module
  File /usr/lib/python2.7/dist-packages/ViewerFramework/VFGUI.py,
 line 21, in module
    import Tkinter, thread, string, Pmw, types
 ImportError: No module named Pmw


 Well then, what's this 'Pmw' that's missing? I thought to myself.  A
 quick google later and I found it: http://pmw.sourceforge.net/

 7.) OK, so that import will fail with an exception due to Pmw being
 missing (if it's not installed), but it'll go unnoticed due to the
 exception handler squashing it.  This however means that the
 ViewerFrameworkGUI class is not always defined, which will cause other
 stuff depending on it to fail mysteriously (as you've found.)  At this
 point, not knowing anything about the packages involved, I'd
 tentatively suggest that 

[Tutor] where does the ViewerFrameWorkGUI come from

2011-12-17 Thread lina
Hi,

I met below issue:

File /usr/lib/python2.7/dist-packages/ViewerFramework/VF.py, line
369, in __init__
self.GUI = ViewerFrameworkGUI(self, title=title,
NameError: global name 'ViewerFrameworkGUI' is not defined


can someone tell me how to examine,

I mean, how to examine, what would you do when you face the problem?

Thanks with best regards,
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor