A man has been shown leniency after explaining he was growing cannabis to use the drug to tackle a genital itch.
Spalding's story was backed in a letter to the court from his doctor
Gregor Spalding admitted cultivating the drug at his home in Blairgowrie.
Perth Sheriff Court heard the 30-year-old was arrested in April after police picked up the crop's smell while at his home looking for someone else.
Sentence was deferred for six months for Spalding to be of good behaviour. He was assured that if he maintained this he would be treated "leniently".
The court was told his "amateurish attempt" to cultivate cannabis was provoked by chronic pain he had suffered for three years.
Spalding said prescription medicine had failed to tackle pain caused by constant itching around his genitals.
He had decided to try using the drug as a painkiller, after reading about it on the internet, and wanted to grow cannabis himself, instead of buying it from a drug dealer.
His doctor wrote a letter to the court confirming Spalding had suffered chronic pain from an itching condition known as pruritus for three years.
The doctor added: "It is quite reasonable that he thought cannabis might help his condition as there have been reports in the press of cannabis relieving pain in multiple sclerosis and other conditions."
The court heard Spalding had not been in trouble with the authorities before and had now been referred to Dundee's Ninewells Hospital.
Sheriff Derek Livingston said: "It does strike me that this isn't a case where someone is growing the plant to supply it to others.
"It was a stupid amateurish attempt. I am prepared to give you a chance. As long as it remains proscribed, you cannot grow cannabis plants in your house."