NYPD Commissioner James O’Neill said, “We failed” 66-year-old schizophrenic Deborah Danner, who was killed in her bedroom as she tried to hit a sergeant with a baseball bat on Tuesday evening.

A somber de Blasio later in the day told reporters that he apologized to Danner’s sister and said that there was no doubt that the use of force against the naked woman was unjustified.

“It was a very painful conversation, to say the least,” de Blasio said of the call. “And I told her how sorry I was, and I told her that we would be there for her in this very, very hard time.”

The mayor called the slaying of Danner, whose relatives said she had a lengthy history of mental illness, “tragic and it is unacceptable.”

Deborah DannerTwitter

“It should never have happened — it’s as simple as that. It should never have happened,” he said.

O’Neill, who succeeded Bill Bratton as commissioner last month, said it appeared the responding cops did not follow a protocol called “isolate and containment.”

“We do have policies and procedures for handling emotionally disturbed people. It looks like some of those procedures weren’t followed,” O’Neill told a breakfast meeting of the Citizens Crime Commission.

Danner’s fatal shooting, he said, was “not how it’s supposed to go. That’s not how we train. Our first obligation is to preserve life.

“My commitment as police commissioner is to find out what went wrong and why. What is clear in this one instance — we failed.”

O’Neill said an investigation would focus in part on why the sergeant who killed Danner didn’t use a Taser instead of his service revolver. He noted that the cop had undergone three days of mandatory, department-wide training on de-escalation techniques.

The recently married Barry, 30 — an eight-year-veteran assigned to the 43rd Precinct — was stripped of his badge and gun pending a probe by the NYPD’s Force Investigation Division.

Barry has not yet undergone a four-day session on dealing with mentally ill people — known as Crisis Intervention Training — that the NYPD rolled out last year, The New York Times reported.

Bronx District Attorney Darcel Clarke also is investigating. State Attorney General Eric Schneiderman, whom Gov. Cuomo last year named special prosecutor for all police killings of unarmed civilians, may also delve into the case.

“Our office is reviewing the incident to determine whether or not it falls within the attorney general’s jurisdiction under the executive order,” a Schneiderman spokeswoman said.

A law-enforcement source said EMS workers arrived at Danner’s apartment at 630 Pugsley Ave. in Castle Hill at around 6 p.m. in response to a 911 call that she was acting erratically.

EMTs called for police backup when Danner refused to drop a pair of scissors and her sister, who had arrived from her nearby home, refused to enter the apartment, the source said.

Danner’s sister, Jennifer Danner, told EMTs that Danner “thinks I’m out to get her and I’m going to kill her,” the source said.

“She was like, ‘No, this is your job and I don’t want anything to do with it,’ ” the source said.

Jennifer Danner (right) talks to the press on Wednesday.David McGlynn

When the cops arrived, the EMTs said they needed Danner handcuffed for transport to the hospital, the source said, and Barry was able to convince her to drop the scissors.

Police have said Danner then approached the sergeant, grabbed a bat and tried to hit him, prompting him to fire two rounds into her torso.

The head of the sergeants union, Ed Mullins, defended Barry and ripped O’Neill for “in essence, denying due process by supplanting public opinion and putting an expectation of results in the minds of the people who will ultimately investigate the case.”

Mullins said investigators at the scene initially deemed the shooting justified until elected officials started raising questions, at which point, he claimed, Chief of Patrol Terence Monahan’s “balls shrink and politics come into play.”

Jennifer Danner blasted the NYPD over the death.

“I was down the hall from my sister’s apartment when I saw the officers rush in, and I heard three gunshots. I asked them if they shot my sister and received no response,” she said.

Wallace Cooke Jr.David McGlynn

She said she wants US Attorney General Loretta Lynch to investigate possible civil-rights violations. Danner was black and Barry is white.

A Danner cousin who’s a retired NYPD officer said that “I had many cases, all mentally ill people . . . I never had to shoot anybody or pull my gun on them.”

“I resent [her] being dead this morning because I would have handled it totally different,” said Wallace Cooke Jr., who said he had served in Harlem’s 26th Precinct.

Cooke said Danner was afflicted by schizophrenia in college, and noted that cops had been to her home “numerous, numerous times over the years.”