1

I have some images that load in my python script.

they reside in c:\Python27\subfolder\images\

in my .py file (which resides in c:\Python27\subfolder\ )

I load them with ./images/file.jpg

It works just fine in IDLE

However when I run the file through notepad++ I get the error:

Failed to load file ./images/file.jpg

How can I fix this with out having to change my actual python code? (It works if I load the images with the full path, but I dont want to do this).

Im using the run command C:\Python27\python.exe "$(FULL_CURRENT_PATH) in notepad++

thank you very much!!

1 Answer 1

2

Well to help you fix the problem, you should do this

import os
print os.getcwd() #gets the current working directory

Most likely your problem is that within the IDE, your CWD differs than when you're running it from the console.

If you want it to work like it does in the IDE, you should first get yourself (the console) within that directory, via navigation (os.chdir(...) command).

You could also make a batch/bash file that runs the python script from the directory you need, and call that file from wherever you want (it would still call the python script with the path you gave

1
  • ahhhh, I understand now. Note pad is using its own directory as the working directory, while IDLE uses its own. Makes perfect sense, I feel embarrassed for not realizing thats what was going on. Thank you for answering my question!
    – Daniel H
    Commented Apr 22, 2013 at 0:37

Not the answer you're looking for? Browse other questions tagged or ask your own question.