Render scene with background jpg in python
I tried the same thing above, but didn't work. What worked for me is with the textures. In this case, I think you also have to take care of the Texture fields. 


bpy.data.textures['Texture.001'].image=bg_img


It works if you need to Change just background

Also add this,


bpy.context.scene.world.use_sky_paper = True
Set also influence, horizontal


Sorry, I dont have enough credits to comment!