py2exe ImportError & data_files

Yes my program works but...

1. I got error messages:
   a. 'ImportError: No module named warnings
   b. 'warning: use func(**args, **kwargs) instead of
apply(func, args, kwargs)' in unlimited number of line
i got this

2. I change my setup.py:
from distutils.core import setup
import os
import glob
import py2exe

setup(name = 'DedeKusmana',
      version = '0.1',
      scripts = ['DedeKusmana.py'],
      data_files = [("bitmaps",
glob.glob(os.path.join("splash.gif"))), ("icon",
glob.glob(os.path.join("TriaSOK.ico"))),("html",
glob.glob(os.path.join(("Aktivitas.htm"))))],
)

the result it creates those directory but strange
thing the program cannot load all of these additional
files. But when I put those files in the same
directory with the main program it works. What's
wrong??

danu

···

__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com

i also tried to use the py2exe, but it will not create an exe file. instead
when i run the setup.py it displays a dialogue with the question:
"do you want to exit altogether? yes no"
my program of setup.py :

from distutils.core import setup
import py2exe

setup(name='testcase',
      version='1.0',
      script=['savemodule.py'],
      )
why does it not create an exe file..i do not even get warnings..but only the
dialogue...??

Stephan

···

-----Original Message-----
From: danu kusmana [mailto:danu_milis@yahoo.com]
Sent: Tuesday, June 10, 2003 10:08 AM
To: wxpython
Subject: [wxPython-users] py2exe ImportError & data_files

Yes my program works but...

1. I got error messages:
   a. 'ImportError: No module named warnings
   b. 'warning: use func(**args, **kwargs) instead of
apply(func, args, kwargs)' in unlimited number of line
i got this

2. I change my setup.py:
from distutils.core import setup
import os
import glob
import py2exe

setup(name = 'DedeKusmana',
      version = '0.1',
      scripts = ['DedeKusmana.py'],
      data_files = [("bitmaps",
glob.glob(os.path.join("splash.gif"))), ("icon",
glob.glob(os.path.join("TriaSOK.ico"))),("html",
glob.glob(os.path.join(("Aktivitas.htm"))))],
)

the result it creates those directory but strange
thing the program cannot load all of these additional
files. But when I put those files in the same
directory with the main program it works. What's
wrong??

danu

__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

danu kusmana wrote:

Yes my program works but...

1. I got error messages:
   a. 'ImportError: No module named warnings
   b. 'warning: use func(**args, **kwargs) instead of
apply(func, args, kwargs)' in unlimited number of line
i got this

This is because you are using Python 2.3 and it implicitly tried to import warnings and then issue a deprecation warning about using apply. wxPython uses apply in all the wrapped methods to invoke the C++ methods (but that is changed in 2.4.1.)

To fix this you can either use Python 2.2 or tell py2exe to include the warnings module when it bundles everything.

2. I change my setup.py:
from distutils.core import setup
import os
import glob
import py2exe

setup(name = 'DedeKusmana',
      version = '0.1',
      scripts = ['DedeKusmana.py'],
      data_files = [("bitmaps",
glob.glob(os.path.join("splash.gif"))), ("icon",
glob.glob(os.path.join("TriaSOK.ico"))),("html",
glob.glob(os.path.join(("Aktivitas.htm"))))],
)

the result it creates those directory but strange
thing the program cannot load all of these additional
files. But when I put those files in the same
directory with the main program it works. What's
wrong??

What pathname do you use when loading the files?

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

It still doesn't work I tried:

1. python setup.py py2exe -f -i warnings
2. python setup.py py2exe -f --force-imports warnings
3. I even add 'import warnings' in my wxApp

None of these works.

Why?

danu

···

--- Robin Dunn <robin@alldunn.com> wrote:

danu kusmana wrote:
> Yes my program works but...
>
> 1. I got error messages:
> a. 'ImportError: No module named warnings
> b. 'warning: use func(**args, **kwargs) instead
of
> apply(func, args, kwargs)' in unlimited number of
line
> i got this

This is because you are using Python 2.3 and it
implicitly tried to
import warnings and then issue a deprecation warning
about using apply.
  wxPython uses apply in all the wrapped methods to
invoke the C++
methods (but that is changed in 2.4.1.)

To fix this you can either use Python 2.2 or tell
py2exe to include the
warnings module when it bundles everything.

>

__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com

stephan huijgen <s.huijgen@student.tudelft.nl> writes:

i also tried to use the py2exe, but it will not create an exe file. instead
when i run the setup.py it displays a dialogue with the question:
"do you want to exit altogether? yes no"
my program of setup.py :

from distutils.core import setup
import py2exe

setup(name='testcase',
      version='1.0',
      script=['savemodule.py'],
      )
why does it not create an exe file..i do not even get warnings..but only the
dialogue...??

Do you run setup.py from a GUI (Pythonwin, pycrust, idle, ...)?

Thomas

yes from python2.2 for windows..
stephan

···

-----Original Message-----
From: Thomas Heller [mailto:theller@python.net]
Sent: Wednesday, June 11, 2003 3:07 PM
To: wxPython-users@lists.wxwindows.org
Subject: Re: [wxPython-users] py2exe ImportError & data_files

stephan huijgen <s.huijgen@student.tudelft.nl> writes:

i also tried to use the py2exe, but it will not create an exe file.

instead

when i run the setup.py it displays a dialogue with the question:
"do you want to exit altogether? yes no"
my program of setup.py :

from distutils.core import setup
import py2exe

setup(name='testcase',
      version='1.0',
      script=['savemodule.py'],
      )
why does it not create an exe file..i do not even get warnings..but only

the

dialogue...??

Do you run setup.py from a GUI (Pythonwin, pycrust, idle, ...)?

Thomas

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

[Please don't top post, it's a pain to clean this up]

stephan huijgen <s.huijgen@student.tudelft.nl> writes:

> > i also tried to use the py2exe, but it will not create an exe file.
> > instead when i run the setup.py it displays a dialogue with the
> > question: "do you want to exit altogether? yes no" my program of
> > setup.py :
> >
> > from distutils.core import setup
> > import py2exe
> >
> > setup(name='testcase',
> > version='1.0',
> > script=['savemodule.py'],
> > )
  
> > why does it not create an exe file..i do not even get warnings..but
> > only the dialogue...??
>
> Do you run setup.py from a GUI (Pythonwin, pycrust, idle, ...)?
>

yes from python2.2 for windows..

You should run 'setup.py py2exe' from the command line (some call it
DOS-Box)

Thomas

danu kusmana wrote:

···

--- Robin Dunn <robin@alldunn.com> wrote:

danu kusmana wrote:

Yes my program works but...

1. I got error messages:
  a. 'ImportError: No module named warnings
  b. 'warning: use func(**args, **kwargs) instead

of

apply(func, args, kwargs)' in unlimited number of

line

i got this

This is because you are using Python 2.3 and it
implicitly tried to import warnings and then issue a deprecation warning
about using apply. wxPython uses apply in all the wrapped methods to
invoke the C++ methods (but that is changed in 2.4.1.)

To fix this you can either use Python 2.2 or tell
py2exe to include the warnings module when it bundles everything.

> It still doesn't work I tried:
>
> 1. python setup.py py2exe -f -i warnings
> 2. python setup.py py2exe -f --force-imports warnings
> 3. I even add 'import warnings' in my wxApp
>
> None of these works.
>
> Why?
>

Thomas (Heller), do you have any ideas on this one?

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin Dunn <robin@alldunn.com> writes:

danu kusmana wrote:
> It still doesn't work I tried:
>
> 1. python setup.py py2exe -f -i warnings
> 2. python setup.py py2exe -f --force-imports warnings
> 3. I even add 'import warnings' in my wxApp
>
> None of these works.
>
> Why?
>

Thomas (Heller), do you have any ideas on this one?

I tried to find out, and the reason seems to be that Python 2.3 tries to
import warnings very early, when the py2exe import hook is not yet
installed. Trying to 'import warnings' later, at the top of the script
for example, succeeds, so it seems to be possible to suppress the
warnings about using apply for example. But the initial ImportError
message remains. And you can open the exe-file with Winzip, and you'll
see that warnings.pyc is indeed included, even without using the '-i
warnings' option.

My usual test script, when the exe-file is run, prints this:

    C:\test>dist\test_wx\test_wx
    ImportError: No module named warnings
    warning: use func(*args, **kwargs) instead of apply(func, args, kwargs)
    warning: use func(*args, **kwargs) instead of apply(func, args, kwargs)
    warning: use func(*args, **kwargs) instead of apply(func, args, kwargs)
    warning: use func(*args, **kwargs) instead of apply(func, args, kwargs)
    warning: use func(*args, **kwargs) instead of apply(func, args, kwargs)
    warning: use func(*args, **kwargs) instead of apply(func, args, kwargs)
    warning: use func(*args, **kwargs) instead of apply(func, args, kwargs)
    warning: use func(*args, **kwargs) instead of apply(func, args, kwargs)
    warning: use func(*args, **kwargs) instead of apply(func, args, kwargs)

And here is the script:

    from wxPython.wx import *

    class MyApp(wxApp):
        def OnInit(self):
            frame = wxFrame(NULL, -1, "Hello from wxPython")
            frame.Show(true)
            self.SetTopWindow(frame)
            return true

    app = MyApp(0)
    app.MainLoop()

Thomas

I'm not on my Windows box right now so I have some probably simple questions...

Thomas Heller wrote:

I tried to find out, and the reason seems to be that Python 2.3 tries to
import warnings very early, when the py2exe import hook is not yet
installed.

Does it have this problem with other apps too or is there something happening real early in wxPython that is causing it?

Trying to 'import warnings' later, at the top of the script
for example, succeeds, so it seems to be possible to suppress the
warnings about using apply for example. But the initial ImportError
message remains.

Does incuding a warnings.py in the dir with the .exe do the right thing?

And you can open the exe-file with Winzip, and you'll
see that warnings.pyc is indeed included, even without using the '-i
warnings' option.

My usual test script, when the exe-file is run, prints this:

    C:\test>dist\test_wx\test_wx
    ImportError: No module named warnings
    warning: use func(*args, **kwargs) instead of apply(func, args, kwargs)

Well the warning messages for apply should all go away in 2.4.1 since all the swig generated wrapper code is no longer using it.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin Dunn <robin@alldunn.com> writes:

I'm not on my Windows box right now so I have some probably simple
questions...

Thomas Heller wrote:
> I tried to find out, and the reason seems to be that Python 2.3 tries to
> import warnings very early, when the py2exe import hook is not yet
> installed.

Does it have this problem with other apps too or is there something
happening real early in wxPython that is causing it?

It is not wxPython specific, happens with other scripts as well.

> Trying to 'import warnings' later, at the top of the script
> for example, succeeds, so it seems to be possible to suppress the
> warnings about using apply for example. But the initial ImportError
> message remains.

Does incuding a warnings.py in the dir with the .exe do the right thing?

Yes, but you need quite a lot of other modules in the dir as well:

copy_reg linecache ntpath os re sre sre_compile sre_constants sre_parse
stat string types UserDict warnings

> And you can open the exe-file with Winzip, and you'll
> see that warnings.pyc is indeed included, even without using the '-i
> warnings' option.
> My usual test script, when the exe-file is run, prints this:

> C:\test>dist\test_wx\test_wx

> ImportError: No module named warnings
> warning: use func(*args, **kwargs) instead of apply(func, args, kwargs)
> warning: use func(*args, **kwargs) instead of apply(func, args, kwargs)
> warning: use func(*args, **kwargs) instead of apply(func, args, kwargs)
> warning: use func(*args, **kwargs) instead of apply(func, args, kwargs)
> warning: use func(*args, **kwargs) instead of apply(func, args, kwargs)
> warning: use func(*args, **kwargs) instead of apply(func, args, kwargs)
> warning: use func(*args, **kwargs) instead of apply(func, args, kwargs)
> warning: use func(*args, **kwargs) instead of apply(func, args, kwargs)
> warning: use func(*args, **kwargs) instead of apply(func, args, kwargs)

Well the warning messages for apply should all go away in 2.4.1 since
all the swig generated wrapper code is no longer using it.

I've read this in your post. My point was that I hoped it would be
possible to suppress the printing of these warnings (in the current
version) with a filter.

Thomas

Thomas Heller <theller@python.net> writes:

Robin Dunn <robin@alldunn.com> writes:

> I'm not on my Windows box right now so I have some probably simple
> questions...
>
> Thomas Heller wrote:
> > I tried to find out, and the reason seems to be that Python 2.3 tries to
> > import warnings very early, when the py2exe import hook is not yet
> > installed.
>
> Does it have this problem with other apps too or is there something
> happening real early in wxPython that is causing it?

It is not wxPython specific, happens with other scripts as well.

Looking at the source I see that Py_Initialize() already does
PyImport_ImportModule("warnings"). The py2exe import hook is installed
later.

Besides: I intend to change py2exe so that it uses the frozen module
mechanism instead of imputil, idea stolen from cx_Freeze also
does. Apart from beeing 'more compatible' than imputil, it also has the
advantage that the frozen modules can be installed before
Py_Initialize() is called, and so the issue with warnings will also be
solved.

Thomas

Thomas Heller wrote:

Besides: I intend to change py2exe so that it uses the frozen module
mechanism instead of imputil, idea stolen from cx_Freeze also
does. Apart from beeing 'more compatible' than imputil, it also has the
advantage that the frozen modules can be installed before
Py_Initialize() is called, and so the issue with warnings will also be
solved.

Cool.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!