[Tutor] Path?

Jim Byrnes jf_byrnes at comcast.net
Wed Jul 14 00:27:32 CEST 2010

Adam Bark wrote:
> On 13 July 2010 14:43, Jim Byrnes<jf_byrnes at comcast.net>  wrote:
>> Steven D'Aprano wrote:
>> My apologizes to Steven and the list, when I replied originally I messed up
>> and sent it to him privately which was not my intention.
>>> On Mon, 12 Jul 2010 03:42:28 am Jim Byrnes wrote:
>>>> I am running Ubuntu.  I downloaded the source code examples for a
>>>> book I purchased.  Some of the examples load image files located in
>>>> the same directory as the program.  If I go to the current directory
>>>> in the terminal the program can use the image files.  However, if I
>>>> use a launcher or the filemanager it pops up an error dialog saying
>>>> the file does not exist even though it is in the same directory.
>>>> The program simply uses the files name.  Is there a way without
>>>> editing the source and inserting the full path to run the program
>>>> from a launcher or the filemanager and allow it to see files in the
>>>> current directory?
>>> What file manager are you using? Nautilus? Konqueror? Something else?
>> Nautilus. I have it configured to run files with the extension .py when
>> they are double clicked.
>>> What do you mean, "use a launcher"? Use a launcher to do what? What sort
>>> of launcher?
>> It runs programs and sits on the panel at the top of my Ubuntu desktop.
>>   The command it uses is usr/bin/python2.6.  These are wxPython examples I am
>> working with.
>>> What pops up an error dialog? The launcher?
>> I am assuming Python. The title bar of the dialog says Python2 Error, the
>> message is   Can't load image from file 'wxPython.jpg': file does not exist.
>>> Which file does it claim doesn't exist? Python? The Python script? The
>>> image file? What is the exact error message it gives?
>> See above.  The line that triggers the error is:  image =
>> wx.Image('wxPython.jpg', wx.BITMAP_TYPE_JPEG)
>>> There's probably a way to tell the launcher which working directory to
>>> use, but of course that depends on the answers to the above questions.
>> If I use the terminal to start the program it has no problem using the
>> file.  There are multiple files in multiple directories so I was looking for
>> a way to just double click them and have them run.  If it turns out that I
>> must make changes to or for each of the files it will be easier to just keep
>> using the terminal.  I've only been using Ubuntu for a few months so I was
>> surprised that the program could not see a file that is in the same
>> directory.
>> Regards,  Jim
> The problem is ubuntu doesn't run the script from the directory it's in so
> it's looking for wxPython.jpg somewhere else.

OK, I mistakenly thought that double-clicking on file in Nautilus would 
take care of the path info.

In my reply above I also mentioned that I tried by dropping it on a 
Launcher on the top panel and that the command the launcher uses is 
usr/bin/python2.6.  Is there a way that the command can be changed so 
that it will look in the same directory the python script is in for any 
file it needs?

Thanks,  Jim

More information about the Tutor mailing list