By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,742 Members | 1,224 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,742 IT Pros & Developers. It's quick & easy.

wxPy + Py2Exe + sys.argv[0]

P: n/a
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

Jul 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.