wxPy + Py2Exe + sys.argv[0]

Miki Tebeka miki.tebeka at zoran.com
Tue Jul 5 08:01:22 CEST 2005


Hello fowlertrainer,

> Hi !
> 
> The problem that when I started the program from CMD, the sys.argv is 
> show the good path (in my machine the c:\dev\xxxx...) from Dialog1.py.
> But when I compile it with Py2Exe, and try to start the exe, it has been 
> not found the hwinfo.ini file what store the setup informations of the 
> program.
This is intensional, py2exe stores some modules in the zip files and want
Python to find them first.

> def LoadIniFile():
>     s=os.path.dirname(sys.argv[0])+'/hwinfo.ini'
>     f=open(s,'r')
>     l=(f.read()).split('\n')
>     d={}
>     for s in l:
>         if s.find('=')<>-1:
>            sl=s.split('=')
>            sl[0]=sl[0].strip().lower()
>            sl[1]=sl[1].strip()
>            d[sl[0]]=sl[1]
>     return d
> 
> So that folder is must be correct !
> 
> Why I get error ? What I can do if I want to use it as normal py ?
I usually have something like the following in my code.

    from os.path import isfile, dirname
    from sys import path

    APPDIR = path[0] # Application directory
    if isfile(APPDIR): # py2exe
        APPDIR = dirname(APPDIR)

HTH.
--
------------------------------------------------------------------------
Miki Tebeka <miki.tebeka at zoran.com>
http://tebeka.bizhat.com
The only difference between children and adults is the price of the toys
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 193 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20050705/dc489546/attachment.sig>


More information about the Python-list mailing list