Run blender Still rendering from command line with external Python script first of all, thanks for the help you have provided me indirectly through this forum.

I am trying to generate still pictures using blender. I have the python script and the model which are both functioning well but i would like to take the script out of the blender file to be able to generate it with an external macro.

I can currently generate the picture by running the python script from the GUI. I am also able to generate the picture from the command line if I call the script saved within the blender file (Internal_Script.py is inside the blender file).:
"C:\Program Files\Blender Foundation\Blender\blender.exe" --background model.blend --python Internal_Script.py  -f 1

however, if I take the content of this script and copy it in a file alongside the blend file, it doesn't work any more (External_Script.py is a separate file now).
"C:\Program Files\Blender Foundation\Blender\blender.exe" --background model.blend --python External_Script.py  -f 1

the python script is definitely being read as i get an error if I misspell the filename. 

Error: Cannot render, no camera


This is quite strange as there is definitely a camera and the script works just fine if it's saved in the blender file.

Would you have any idea about what's going on?
Check that bpy.context.scene.camera is set to your newly added camera. That property determines which camera is used for rendering, and if it's still None it won't work.