Py 3: Terminal script can't find relative path

G

Gnarlodious

I am running a script in a browser that finds the file in subfolder
Data:

Content=Plist('Data/Content.plist')

However, running the same script in Terminal errors:

IOError: [Errno 2] No such file or directory: 'Data/Content.plist'

Is Py 3 unable to find relative paths? I tried all kinds of tricks to
no avail. What is wrong?

-- Gnarlie
 
J

John Bokma

Gnarlodious said:
I am running a script in a browser that finds the file in subfolder
Data:

Content=Plist('Data/Content.plist')

However, running the same script in Terminal errors:

IOError: [Errno 2] No such file or directory: 'Data/Content.plist'

What does:

ls -l Data/Content.plist

in the terminal give?
 
G

Gnarlodious

Gnarlodious said:
I am running a script in a browser that finds the file in subfolder
Data:

However, running the same script in Terminal errors:
IOError: [Errno 2] No such file or directory: 'Data/Content.plist'

What does:

ls -l Data/Content.plist

in the terminal give?

I can replace with absolute paths and it works as expected. Could this
be a Python 3 bug? Where as a CGI script it finds the relative path
but not in Terminal?

-- Gnarlie
 
N

nn

Gnarlodious said:
I am running a script in a browser that finds the file in subfolder
Data:
Content=Plist('Data/Content.plist')
However, running the same script in Terminal errors:
IOError: [Errno 2] No such file or directory: 'Data/Content.plist'
What does:
ls -l Data/Content.plist
in the terminal give?

I can replace with absolute paths and it works as expected. Could this
be a Python 3 bug? Where as a CGI script it finds the relative path
but not in Terminal?

-- Gnarlie

Stop and think for a second what you are saying: It works with
absolute paths, it works as CGI script with relative paths, it doesn't
work in the terminal. What is different? Do you know for sure what
folder you are starting at when using the relative path? Most likely
the terminal starts in a different place than the CGI script.
 
G

Gnarlodious

OK I guess that is normal, I fixed it with this:

path=os.path.dirname(__file__)+"/Data/"

-- Gnarlie
 

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,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top