Fabio Balliu, 23, of Main Street, Huthwaite, near Mansfield, was arrested at the property in Spring Gardens after officers were initially alerted by a suspicious neighbour who believed a burglary was taking place.
Lincoln Crown Court heard police were first called about the prospective burglary at 2am on May 17, 2021.
Officers attended at 10am the following morning and could immediately smell cannabis coming from inside the property and the sound of electric fans.
Balliu unlocked the front door and ran from the property but was stopped and arrested.
He told the officers: "Okay, I'm from Albania. My English isn't good."
Police found a living area in the front room with a couch bed and empty freezer which suggested the grower was possibly not living in the property.
Three growing areas were found in the house, with 87 cannabis plants in the flowering stage, and 84 cannabis plants in a vegetative state.
Police also searched Balliu's home address in Nottinghamshire and found receipts from a DiY store in Sutton.
A drugs expert estimated the potential value of the cannabis at between £24,500 and £102,600 depending on the quantity and how it was sold.
Rhys Rosser, mitigating, told the court this was a single operation and Balliu had been on remand in prison since his arrest.
Mr Rosser said that, prior to arriving in the UK, Balliu had worked as a chef but he was unable to get a suitable visa.
Passing sentence Judge Simon Hirst told Balliu: "You were detained while fleeing from the property. There were 171 plants spread out over three growing areas. You played a significant role and regularly travelled from Nottinghamshire to Gainsborough to tend this grow."
Inspector for Gainsborough, Gary Brockie said: “We work really closely with the local community which helps support information we have about drugs and other crimes. If you suspect activity like this is taking place, please do the right thing and let us know.”