I am trying to use blender python script for creating textures in cycles render mode. While executing a script which is to be used to get the nodes, I am getting an attribute error
AttributeErrror: 'NoneType' object has no attribute 'nodes'
Here's the code I am using
import bpy
import os
mat = bpy.data.materials["Material"]
nodes = mat.node_tree.nodes
material_output = nodes.get ("Material Output")
node_texture = nodes.new(type='ShaderNodeTexImage')
node_texture.image = bpy.data.images.load ('C:\\Users\\KM\\Desktop\\Blender\\auto.png')
node_texture.projection = "LINEAR"
links = mat.node_tree.links
link = links.new(node_texture.otputs[0], nodes.get("DIffuse BSDF"),inputs[0])
The error is from the line "nodes = mat.node_tree.nodes". Hope you guys can help clear the doubt.
Apologies if the question seems trivial, I am very new to blender and Thanks in advance for your help