"-Picture" Command file not found, unable to open

I’m trying to write a python script that imports pictures and places them in a document to automate a drawing set. The I am unable to use the “-picture” command and then enter the file name. Every time I do this within the python script it ends up running an error in the command line that states the file is not found or unable to open.

Even if I use the “-picture” command manually and then type in the name of the file it gives me the same error message. I’ve tried with multiple files, file names, file locations etc. If I type in the filename it will return the correct file path but will say " not found, unable to open"

If I use the “picture” command or select browse in the “-picture” command I can select the file from the pop up browser no problem and it imports fine. The problem seems to just be with selecting the file directly from the command line which is what I want to be able to do in order to automate the process.

Any suggestions? I don’t think it is a python issue necessarily. I have copied direct code from other threads that people have suggested and it does not seem to work. I think the problem lies in the “-picture” command itself and its inability to select a file from the command prompt.

Capture 1

In your script, you’ll need to enclose your file name in quotation marks if the path has spaces in it.
“C:\My Documents\Project 44\This Image.jpg”

Hi John, thanks for this. My file path will likely have spaces in it so this will be helpful when I go to write the script. Do you have any advice on the “-picture” command not working when I enter a valid file name? Even with Python and grasshopper closed in a brand new file I can not get to to load a picture by entering the file name. Are there any settings that might interfere with this?

If the file isn’t a supported format, like a CMYK jpg could act that way.
Basically, if you can type the script one command and input at a time from the keyboard, and get it to work, it should work.

If you’re running in a non-English Rhino then you would want to use “-_Picture”