wxPy + Py2Exe + sys.argv[0]

fowlertrainer at anonym.hu fowlertrainer at anonym.hu
Mon Jul 4 10:49:22 EDT 2005


Hi !

I have been finished my WMI information getter simple application, but 
the exe is not working as like the py modules before compilation.

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 file is write by my hand, and I place it with Dialog1.exe (in same 
directory).

But the compiled exe is not use the good path... It use "/" only.

When I started it from CMD with Dialog1.exe, it hasn't been found the 
ini file:

Traceback (most recent call last):
  File "Dialog1.py", line 269, in ?
  File "Dialog1.py", line 201, in LoadIniFile
IOError: [Errno 2] No such file or directory: '/hwinfo.ini'

When I use full path: c:\dev\xxxx\Dialog1.exe, it have been found 
everything, and working good.
I don't understand it, because I working with sys.argv[0], with this method:

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 ?

Thanx for help:
   ft




More information about the Python-list mailing list