0

i'm trying to run an exe file (say foo.exe) using python script exported to exe (say boo.exe) using py2exe, it always give the below error as can't find the specified file, but i'm pretty sure the foo.exe is exist and on same directory with boo.exe, the code works fine before exporting the script into exe !

WindowsError: [Error 2] The system cannot find the file specified: 'C:\\Users\\test\\Desktop\\foo.exe'

the code is

os.startfile("foo.exe")

is it somekind of bug or limitation like this one

client eastwood
  • 103
  • 2
  • 8
  • 1
    have you tried different commands to run executable file? for example, `os.popen('foo.exe')`? – Andersson Jun 30 '15 at 13:14
  • Do you have your `exe` present under `Desktop`? Or is it your `cwd`? – shaktimaan Jun 30 '15 at 13:23
  • Don't depend on the working directory to find files relative to your script or executable. See http://stackoverflow.com/q/2292703. – Eryk Sun Jun 30 '15 at 14:41
  • @eryksun i tried to hardcode the absoulte path of the foo.exe file but it doesn't work either ! , for example i tried os.startfile("C:\\Users\\test\\Desktop\\foo.exe") with no sucess – client eastwood Jun 30 '15 at 22:14
  • @Andersson, yes i did and subprocess doesn't work as well – client eastwood Jun 30 '15 at 22:16
  • @shaktimaan both files are on the desktop – client eastwood Jun 30 '15 at 22:16
  • one more point to add, the boo.exe is running on a different windows machine where python is not installed – client eastwood Jun 30 '15 at 22:26
  • @client eastwood No my question was that whether your current working directory is `Desktop` too? When you run `os.startfile()` it looks for that `exe` in `os.getcwd()` and all the locations in `Environment Path` variable. – shaktimaan Jul 01 '15 at 05:08
  • @shaktimaan yes i got your point, but as i said i've explicitly used the absolute path like os.startfile("C:\\Users\\test\\Desktop\\foo.exe") ,,, i also tried to change the current working directory using CWD = os.getcwd() then os.chdir(CWD) but neither did work ! – client eastwood Jul 01 '15 at 07:43

0 Answers0