Trouble getting to windows My Documents directory
python.list at tim.thechases.com
Fri Jul 10 16:46:07 CEST 2015
On 2015-07-10 09:27, Mark Storkamp via Python-list wrote:
> sourcedir = os.environ['HOME']+"/Documents/"
First, I'd do a couple things here to accommodate various systems to
make it cross-platform:
sourcedir = os.path.join(
> src = askopenfilename()
Then, rather than changing to that directory, use
src = askopenfilename(initialdir=sourcedir)
> When this is run from IDLE, it works fine. But when I double click
> on the saved file to run it, it quits without ever showing the open
> file dialog box, and doesn't show any error message.
If the above doesn't solve the problem, you might try writing the
sourcedir to a file so you can see what it thinks you're trying to
> The problem is with the os.environ['HOME'] call. If I comment it
> out (and fix up the surrounding code with an absolute path) then it
> runs. But then it won't work properly for other users.
I suspect that inspecting that sourcedir will show what's going on,
and that the above tweaks will ameliorate the problem.
More information about the Python-list