Hi Le Dahut,

I use the following code for prgrams built with py2exe:

<snip>
import sys
import os
print os.path.dirname(sys.executable)
</snip>

This may work in your situation as well.

Regards,

Andre
http://www.burgaud.com/


On 10/21/05, le dahut <[EMAIL PROTECTED]> wrote:
In fact I build an SFX archive with winrar where I specify a program to
launch once extraction has ended. The program is launched but don't find
it's sub-directory.
If I go to the extracted archive directory an dlbe-clic on " install.exe"
all runs fine, but whit winrar's "Run after extraction" option it
doesn't.


Le vendredi 21 octobre 2005 à 14:42 +0100, Tim Golden a écrit :
> [le dahut]
>
> > I try to get the program's directory, the one where the .exe (or .py)
> is.
>
> >From within Python, sys.argv[0] usually gives you the running
> program (not sure what it does with py2exe etc.). So something
> like (untested):
>
> <code>
> import os, sys
>
> print os.path.dirname (sys.argv[0])
>
> </code>
>
> > With os.getcwd() I get the directory from where the program is
> launched
> > not his directory. The program has to copy some files and thus I get
> an
> > error like "XXXXXX no such file or directory".
>
> Umm. It's not clear why you get "no such file / directory". Surely
> os.getcwd returns *some* real directory. Or is it that you don't
> have permissions to the directory?
>
> > (the DOS box closed to quickly to have the detailed
> > error msg...) where XXXXXX is a sub-directory of
> > the program's one.
>
> I'm assuming you're double-clicking on a Python icon to
> run the program. You might try, instead, running it from
> the command line:
>
> Start > Run > cmd.exe
> (DOS box opens)
> python x:\path\to\my\program.py
>
> This should let you see what's going on.
>
> TJG
>
>
> ________________________________________________________________________
> This e-mail has been scanned for all viruses by Star. The
> service is powered by MessageLabs. For more information on a proactive
> anti-virus service working around the clock, around the globe, visit:
> http://www.star.net.uk
> ________________________________________________________________________
> _______________________________________________
> Python-win32 mailing list
> Python-win32@python.org
> http://mail.python.org/mailman/listinfo/python-win32

_______________________________________________
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

_______________________________________________
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to