startfile problems

T

Timothy Smith

hello i have a very odd issue with os.startfile()

ok basicly my app works perfectly on every single other pc todate. i
cannot recreate this issue on any system. so i've already ruled out any
obvious coding issues, such as wrong file names etc. this issue only
occurs on this one old pc.

upon trying to os.startfile() a pdf document (that i create) i get the
error - Windows error [erro2]"System cannot find the specified file"
however when i go in to the program directory, the file is there, and i
can open it. i have ruled out the following:
the pdf viewer is working.
the path and file name are correct
the path and file name do not contain any spaces and what not.

it's a windows xp system and i'm using python 2.3

i'm very curious as to what everyone thinks
 
D

Dennis Lee Bieber

i'm very curious as to what everyone thinks

I suspect most of us think: Where's the code?
followed by: Where's the traceback?

As for your statement of verifying the path and filename... We
haven't seen it so can't guess... (part of the "where's the code")

Does the path contain \n, \t, \r, \f, etc. If it does, and you
are not using a raw string, you are looking for a file with newline,
tab, carriage return, formfeed, etc. respectively in the name.


fid = "c:\temp\something.pdf" #bad, this is
# c:<tab>emp\something.pdf
# assuming \s isn't some special character

fid = r"c:\temp\something.pdf" #good
fid = "c:\\temp\\something.pds" #okay

--
 
T

Timothy Smith

Dennis said:
I suspect most of us think: Where's the code?
followed by: Where's the traceback?

As for your statement of verifying the path and filename... We
haven't seen it so can't guess... (part of the "where's the code")

Does the path contain \n, \t, \r, \f, etc. If it does, and you
are not using a raw string, you are looking for a file with newline,
tab, carriage return, formfeed, etc. respectively in the name.


fid = "c:\temp\something.pdf" #bad, this is
# c:<tab>emp\something.pdf
# assuming \s isn't some special character

fid = r"c:\temp\something.pdf" #good
fid = "c:\\temp\\something.pds" #okay
it's iterally just

PDFname = 'tmp.pdf'
os.startfile(PDFname)

thats the code.

so obviously it contains no errnous characters. see my update btw. it
actually DOES open the report, but throws up the exception as well.
 
D

Dennis Lee Bieber

it's iterally just

PDFname = 'tmp.pdf'
os.startfile(PDFname)

thats the code.
No "import os"?
And the full traceback?
so obviously it contains no errnous characters. see my update btw. it
actually DOES open the report, but throws up the exception as well.

Must not have made it to my server yet, assuming it was posted
after my comment.

import os

PDFname = "test.pdf"
os.startfile(PDFname)

No errors if I'm in the directory with the PDF when I execute
the program...

E:\UserData\Dennis Lee Bieber\My Documents>script1.py

E:\UserData\Dennis Lee Bieber\My Documents>python script1.py

E:\UserData\Dennis Lee Bieber\My Documents>



--
 
T

Timothy Smith

Dennis said:
No "import os"?
And the full traceback?




Must not have made it to my server yet, assuming it was posted
after my comment.

import os

PDFname = "test.pdf"
os.startfile(PDFname)

No errors if I'm in the directory with the PDF when I execute
the program...

E:\UserData\Dennis Lee Bieber\My Documents>script1.py

E:\UserData\Dennis Lee Bieber\My Documents>python script1.py

E:\UserData\Dennis Lee Bieber\My Documents>
yep the program is executed in the same dir as the pdf file. like i said
it actually opens it, but throws up an exception as well.
if i hadn't seen it with my own eyes i wouldn't believe it.
 
M

Michael Hoffman

Timothy said:
yep the program is executed in the same dir as the pdf file. like i said
it actually opens it, but throws up an exception as well.

You are far more likely to get informed help if you post the traceback
here, as has been suggested twice already.
 
T

Timothy Smith

Michael said:
Timothy Smith wrote:




You are far more likely to get informed help if you post the traceback
here, as has been suggested twice already.
i can't since it's a remote site and i can't reproduce the error. the
best i have is a screen shot.
besdies which the only information it gives is the names and line
numbers of the my py modules, nothing more. the only real info it gives
i have posted already, in my inital post (the last line of it,
WindowsError etc..)

other then that there's no more information to be had. it's a bloody
simple 2 line function, nothing funky about it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top