[Pythonmac-SIG] Re: cwd and PythonLauncher problem -- a bit more info

Jim Harrison jhrsn at pitt.edu
Thu Sep 30 20:54:38 CEST 2004


> Sorry if this has been previously discussed. It appears that when a source
> file is double-clicked and starts with PythonLauncher (2.3), the directory
> of the file is not added to the Python module search paths. Thus other
> modules in that directory cannot be imported without a full path and files
> cannot be read or written using paths relative to the source file.

Sorry, I was inaccurate--importing is not affected. This problem appears to
be specific to opening files. If a script is launched with PythonLauncher
and it attempts to open a file in its own directory using only the name of
the file (no path), it will fail with 'No such file or directory.' If the
program writes a file using a file name only, it appears to write to one of
two places: if it is running within a user directory tree it will write the
file to the root of the user directory; if it is running outside a user
directory (eg., the Applications directory) it will write to the root of the
disk.

My understanding is that relative file paths should be based on the
directory containing the executing script. Programs executed on the Mac from
within IDLE or MacPythonIDE appear to handle the script's directory
correctly under these conditions. Is this a known or fixable issue with
PythonLauncher, or should I be looking for a problem in my installation?

Environment: OSX 10.3.5, Jack's MacPython 2.3 Panther addons

Jim Harrison
Univ. of Pittsburgh



More information about the Pythonmac-SIG mailing list