DrPython and py2exe

Discussion in 'Python' started by mk, Jan 23, 2009.

  1. mk

    mk Guest

    Hello,

    I'm trying to get DrPython to edit .py file on double-click on Windows.

    Sure, I can use trivial .bat file to open DrPython with file as
    argument. But the irritating thing is that DOS window stays open until
    particular instance of DrPython isn't closed.

    py2exe to rescue. I have modified DrPython's setup.py:


    setup(name='drpython.exe',
    version=MY_VER,
    description=description[0],
    long_description=description[1],
    classifiers = filter(None, classifiers.split('\n')),
    author=AUTHOR,
    author_email=AUTHOR_EMAIL,
    url=URL,
    platforms = "any",
    license = 'GPL',
    packages=[ MY_NAME ],
    package_dir={ MY_NAME : '.' },
    package_data={ MY_NAME : DATA },
    scripts=['postinst.py'],
    windows=['drpython.py'],
    )

    py2exe builds application, but when I start it, I get this in the log file:

    Traceback (most recent call last):
    File "drpython.py", line 46, in <module>
    File "wxversion.pyc", line 152, in select
    wxversion.VersionError: Requested version of wxPython not found

    I'm guessing this is because py2exe doesn't package wxPython together
    with the app.

    Since this topic is interesting for me anyway (i.e. how to transform
    wxPython app using py2exe into Windows executable), would someone please
    reply on how to do it?

    Thanks,
    mk
    mk, Jan 23, 2009
    #1
    1. Advertising

  2. mk

    imageguy Guest

    But the irritating thing is that DOS window stays open until
    > particular instance of DrPython isn't closed.



    This is a relatively simple fix I think.
    You can change the extension of the drPython.py to drpython.pyw and
    the python windows
    executable (pythonw.exe) will launch the program instead of the
    traditional
    executable (python.exe).


    > Traceback (most recent call last):
    >    File "drpython.py", line 46, in <module>
    >    File "wxversion.pyc", line 152, in select
    > wxversion.VersionError: Requested version of wxPython not found


    check out the wiki on 'multi version installs'.
    http://wiki.wxpython.org/MultiVersionInstalls

    drPython is probably selecting a specific version of wxpython and
    py2exe doesn't like it or
    can't find it. Once you solve that, py2exe will work fine with
    wxpython.
    imageguy, Jan 23, 2009
    #2
    1. Advertising

  3. mk

    mk Guest

    imageguy wrote:

    > drPython is probably selecting a specific version of wxpython and
    > py2exe doesn't like it or
    > can't find it. Once you solve that, py2exe will work fine with
    > wxpython.


    Thanks, drPython was indeed making use of wxversion.select. What's
    strange is that it was selecting apparently correct version:

    import wxversion
    wxversion.select('2.8')

    I put this in setup.py:

    import wxversion
    wxversion.select("2.8.9.1")
    import wx

    ...and it worked.

    Regards,
    mk
    mk, Jan 23, 2009
    #3
  4. mk

    Armin Guest

    py2exe + SQLite problem

    Hello all,

    I have frozen a running application which is using SQLite with py2exe.

    When I start the exe file I see in the log file of the exe:

    Traceback (most recent call last):
    File "dpconf.py", line 666, in ?
    File "dpconf.py", line 251, in __init__
    File "sqlite\main.pyc", line 255, in execute
    _sqlite.DatabaseError: no such table: genslaveopt

    The table exist in the database file ... no problem with the plain
    python version.

    How can I solve that problem ??

    Best Regards

    --Armin
    Armin, Jan 29, 2009
    #4
  5. Re: py2exe + SQLite problem

    En Thu, 29 Jan 2009 13:05:11 -0200, Armin <> escribió:

    > I have frozen a running application which is using SQLite with py2exe.
    > When I start the exe file I see in the log file of the exe:
    > Traceback (most recent call last):
    > File "dpconf.py", line 666, in ?
    > File "dpconf.py", line 251, in __init__
    > File "sqlite\main.pyc", line 255, in execute
    > _sqlite.DatabaseError: no such table: genslaveopt
    >
    > The table exist in the database file ... no problem with the plain
    > python version.


    Did you solve this problem? As you posted 4 related messages and the last
    one might imply a solution to this first one...

    --
    Gabriel Genellina
    Gabriel Genellina, Jan 29, 2009
    #5
  6. mk

    Armin Guest

    Re: py2exe + SQLite problem

    Gabriel Genellina wrote:
    > En Thu, 29 Jan 2009 13:05:11 -0200, Armin <> escribió:
    >
    >> I have frozen a running application which is using SQLite with py2exe.
    >> When I start the exe file I see in the log file of the exe:
    >> Traceback (most recent call last):
    >> File "dpconf.py", line 666, in ?
    >> File "dpconf.py", line 251, in __init__
    >> File "sqlite\main.pyc", line 255, in execute
    >> _sqlite.DatabaseError: no such table: genslaveopt
    >>
    >> The table exist in the database file ... no problem with the plain
    >> python version.

    >
    > Did you solve this problem? As you posted 4 related messages and the
    > last one might imply a solution to this first one...


    Yes, the distutil option 'data_files' failed to copy the database files
    to the dist directory. All dbopen calls have created empty db files ...

    --Armin

    PS: any comments on the data_files issue ??

    >
    Armin, Jan 30, 2009
    #6
  7. Re: py2exe + SQLite problem

    En Fri, 30 Jan 2009 09:50:08 -0200, Armin <> escribió:
    > Gabriel Genellina wrote:
    >> En Thu, 29 Jan 2009 13:05:11 -0200, Armin <> escribió:
    >>
    >> Did you solve this problem? As you posted 4 related messages and the
    >> last one might imply a solution to this first one...

    >
    > Yes, the distutil option 'data_files' failed to copy the database files
    > to the dist directory. All dbopen calls have created empty db files ...
    >
    > PS: any comments on the data_files issue ??


    Yes: read the section "Installing Additional Files" in the "Distributing
    Python Modules" document
    http://docs.python.org/distutils/setupscript.html#installing-additional-files

    Right at the end: "To install data files directly in the target directory,
    an empty string should be given as the directory."

    setup(...,
    data_files=[
    ('', ['list/of/file/names',
    'perhaps/including/source/directory']),
    ]
    )

    --
    Gabriel Genellina
    Gabriel Genellina, Jan 30, 2009
    #7
  8. mk

    Armin Guest

    Re: py2exe + SQLite problem

    Gabriel Genellina wrote:
    > En Fri, 30 Jan 2009 09:50:08 -0200, Armin <> escribió:
    >>

    >
    > Right at the end: "To install data files directly in the target
    > directory, an empty string should be given as the directory."
    >
    > setup(...,
    > data_files=[
    > ('', ['list/of/file/names',
    > 'perhaps/including/source/directory']),
    > ]
    > )
    >

    Yes ... so far the theory :)

    As posted before ... set's my script (python 2.3):

    from distutils.core import setup
    import py2exe

    setup(windows=['dpconf.py'],
    data_files=[ "", ["proj_db","gsd_db","dachs2.xbm"]]
    )

    When I create the distribution I got the following err msg:

    *** copy data files ***
    warning: install_data: setup script did not provide a directory for ''
    -- installing right in 'C:\pyDPCONF.2.3-dev\dist'
    error: can't copy '': doesn't exist or not a regular file

    Looks a little bit inconsistent ?

    --Armin
    Armin, Jan 31, 2009
    #8
  9. Re: py2exe + SQLite problem

    Armin schrieb:
    > As posted before ... set's my script (python 2.3):
    >
    > from distutils.core import setup
    > import py2exe
    >
    > setup(windows=['dpconf.py'],
    > data_files=[ "", ["proj_db","gsd_db","dachs2.xbm"]]
    > )
    >
    > When I create the distribution I got the following err msg:
    >
    > *** copy data files ***
    > warning: install_data: setup script did not provide a directory for ''
    > -- installing right in 'C:\pyDPCONF.2.3-dev\dist'
    > error: can't copy '': doesn't exist or not a regular file


    From the Python docs (chapter 'writing the setup script):

    """
    data_files specifies a sequence of (directory, files) pairs in the following way:

    setup(...,
    data_files=[('bitmaps', ['bm/b1.gif', 'bm/b2.gif']),
    ('config', ['cfg/data.cfg']),
    ('/etc/init.d', ['init-script'])]
    )
    """

    So, it looks like you should use

    > setup(windows=['dpconf.py'],
    > data_files=[("", ["proj_db","gsd_db","dachs2.xbm"])]

    ^ ^
    > )


    Thomas
    Thomas Heller, Jan 31, 2009
    #9
  10. Re: py2exe + SQLite problem

    En Sat, 31 Jan 2009 11:51:16 -0200, Armin <> escribió:
    > Gabriel Genellina wrote:
    >> En Fri, 30 Jan 2009 09:50:08 -0200, Armin <> escribió:


    >> Right at the end: "To install data files directly in the target
    >> directory, an empty string should be given as the directory."
    >> setup(...,
    >> data_files=[
    >> ('', ['list/of/file/names',
    >> 'perhaps/including/source/directory']),
    >> ]
    >> )
    >>

    > Yes ... so far the theory :)
    >
    > As posted before ... set's my script (python 2.3):


    You didn't tell us that you were using version 2.3 -- it's important, as
    the current stable releases are 2.6 and 3.0. Anyway, this should work in
    2.3 too.

    > from distutils.core import setup
    > import py2exe
    >
    > setup(windows=['dpconf.py'],
    > data_files=[ "", ["proj_db","gsd_db","dachs2.xbm"]]
    > )
    >


    Comparing my example and yours, you lack a parenthesis level:

    setup(windows=['dpconf.py'],
    data_files=[("", ["proj_db","gsd_db","dachs2.xbm"])]
    )

    > When I create the distribution I got the following err msg:
    >
    > *** copy data files ***
    > warning: install_data: setup script did not provide a directory for ''
    > -- installing right in 'C:\pyDPCONF.2.3-dev\dist'
    > error: can't copy '': doesn't exist or not a regular file
    >
    > Looks a little bit inconsistent ?


    O thou of little faith, try again...

    --
    Gabriel Genellina
    Gabriel Genellina, Jan 31, 2009
    #10
  11. mk

    Armin Guest

    Re: py2exe + SQLite problem

    Hello,

    Thanks to all ... it's working now !

    Google isn't always your friend :) I found in the net a lot but wrong
    examples for specification of "data_files". Now I have the correct one.

    Best Regards

    --Armin



    Gabriel Genellina wrote:
    > En Sat, 31 Jan 2009 11:51:16 -0200, Armin <> escribió:
    >> Gabriel Genellina wrote:
    >>> En Fri, 30 Jan 2009 09:50:08 -0200, Armin <> escribió:

    >
    >>> Right at the end: "To install data files directly in the target
    >>> directory, an empty string should be given as the directory."
    >>> setup(...,
    >>> data_files=[
    >>> ('', ['list/of/file/names',
    >>> 'perhaps/including/source/directory']),
    >>> ]
    >>> )
    >>>

    >> Yes ... so far the theory :)
    >>
    >> As posted before ... set's my script (python 2.3):

    >
    > You didn't tell us that you were using version 2.3 -- it's important, as
    > the current stable releases are 2.6 and 3.0. Anyway, this should work in
    > 2.3 too.
    >
    >> from distutils.core import setup
    >> import py2exe
    >>
    >> setup(windows=['dpconf.py'],
    >> data_files=[ "", ["proj_db","gsd_db","dachs2.xbm"]]
    >> )
    >>

    >
    > Comparing my example and yours, you lack a parenthesis level:
    >
    > setup(windows=['dpconf.py'],
    > data_files=[("", ["proj_db","gsd_db","dachs2.xbm"])]
    > )
    >
    >> When I create the distribution I got the following err msg:
    >>
    >> *** copy data files ***
    >> warning: install_data: setup script did not provide a directory for ''
    >> -- installing right in 'C:\pyDPCONF.2.3-dev\dist'
    >> error: can't copy '': doesn't exist or not a regular file
    >>
    >> Looks a little bit inconsistent ?

    >
    > O thou of little faith, try again...
    >
    Armin, Feb 1, 2009
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. john
    Replies:
    2
    Views:
    343
  2. Stephane Roy
    Replies:
    3
    Views:
    1,146
    monkey
    May 4, 2005
  3. dcrespo
    Replies:
    0
    Views:
    339
    dcrespo
    May 9, 2005
  4. Laszlo Zsolt Nagy

    How to use DrPython plugins

    Laszlo Zsolt Nagy, Aug 6, 2005, in forum: Python
    Replies:
    3
    Views:
    1,883
    Franz Steinhaeusler
    Aug 8, 2005
  5. Pandiani

    DrPython debugger

    Pandiani, Sep 4, 2005, in forum: Python
    Replies:
    6
    Views:
    458
    Colin J. Williams
    Sep 9, 2005
Loading...

Share This Page