R. Kelly has a week to pay more than $173,000 in back rent to his landlord and other court fees or he’ll be evicted from the warehouse he rents on the Near West Side.

Court records show that Kelly has until Jan. 21 to pay $166,981 to the owner of the property at 219 N. Justine St. Additionally, he must also pay $6,122 in attorneys’ fees and $780 in court costs.

The agreed order was entered on Jan. 7. It’s unclear if Kelly has yet to make any payments to Midwest Commercial Funding — the company that owns, and is currently selling, the building. The attorney handling Kelly’s property cases did not respond to a request for comment Monday.

The Near West Side warehouse, where Kelly is the only tenant, has come under scrutiny in recent weeks since the airing of a documentary series on Lifetime that detailed a host of allegations of sexual impropriety by Kelly — mostly involving underage girls. He has repeatedly denied the allegations.

Similar allegations have dogged Kelly throughout his career and were first reported by the Sun-Times in 2000. He has not been charged with any crimes since he was acquitted of child pornography charges in 2008.

Kelly’s possible eviction comes as inspectors from the city’s Department of Buildings prepare to go into the warehouse and look for changes that, city attorneys say, were made to the building illegally.

Last week, city attorneys filed an emergency motion in Cook County Circuit Court, asking a judge to grant them access to the building. They alleged that, though the building is zoned for industrial uses, it was serving as a residence. Also, city attorneys said, a recording studio inside was illegal.

On Friday, Circuit Court Judge Patrice Ball-Reed ordered that the inspectors be allowed in, but the inspection was scheduled for noon Wednesday. Kelly’s attorney, Melvin Sims, had asked that the inspection take place in 30 days.

An attorney for Midwest Commercial Funding told the judge that the building owners “don’t have a key” and couldn’t get inside, either.

A copy of Kelly’s lease, included in the case file, shows that Midwest Commercial Funding gave Kelly permission to make several alterations to the property that are at the heart of the city’s motion.

“Landlord hereby grants permission to Tenant to modify the existing recording studios to meet Tenant’s specific needs as well as create an apartment type area on the second floor,” the lease reads.

Midwest Commercial Funding’s attorney did not respond to a request for comment Monday.

On Jan. 8, Cook County State’s Attorney Kim Foxx made a public plea for accusers to come forward so that the office could investigate allegations against Kelly. Foxx said she has not — and cannot — open a criminal probe in the absence of cooperating witnesses.

Two women contacted the Sun-Times the next day and gave accounts of what they allegedly experienced at the hands of Kelly. Soon after, the called the number publicized by Foxx and left voicemails with prosecutors.

On Monday, one woman told the Sun-Times that she had yet to hear back from the state’s attorney’s office. The other one did hear back but said in a text message: “I don’t want to go forward with the case at all due to my own personal reasons.”