Python 2.8 - why does linking the image texture node throw an error? In Blender/Python 2.8, I am trying to create an image texture node for an object.  The last line of the code below throws this error:

AttributeError: 'NoneType' object has no attribute 'inputs'

I tried replacing 'Diffuse BSDF' with 'ShaderNodeTexImage' and it still threw the same error.

Your suggestions would be much appreciated.  Thanks in advance.

material = bpy.data.materials.get(material_name)
if material is None:
    material = bpy.data.materials.new(material_name)
material.use_nodes=True
nodes = material.node_tree.nodes
material_output = nodes.get("Material Output")
path=TextureFolder+TextureFilenamePost
imgTex = bpy.data.images.load(path)
node_texture = nodes.new(type='ShaderNodeTexImage')
node_texture.image = imgTex
node_texture.location = 0,200
links = material.node_tree.links
link = links.new(node_texture.outputs[0], nodes.get("Diffuse BSDF").inputs[0])
This happens because there is no Diffuse BSDF in your material. If you create a new material with bpy.data.materials.new() it will contain only as Principle BSDF and Material Output Node. You need to create the Diffuse BSDF node first.

nodes.get("Diffuse BSDF") returns None because it can't find a node with that name. The error occurs when you try to access input[0], which as the errors says, is no attribute of NoneType.