MADRID (AP) - Authorities in Spain say a judge has ordered an autopsy for John McAfee, the gun-loving antivirus pioneer, cryptocurrency promoter and occasional politician who died in a prison cell pending extradition to the United States for allegedly evading millions in unpaid taxes.

A court spokeswoman for the Catalonia region said Thursday that a forensic team would need to perform toxicology tests on McAfee's body to determine the cause of death and that results could take “days or weeks.”

Authorities say everything at the scene indicated that the 75-year-old tycoon killed himself.

The judicial investigation is being handled by a court in Martorell, a town northwest of Barcelona with jurisdiction over the prison where McAfee died. The spokeswoman wasn't authorized to be identified by name in media reports.

McAfee's Spanish lawyer, Javier Villalba, said the entrepreneur's death had come as a surprise to his wife and other relatives, adding he would seek to get “to the bottom” of his client's death.

“This has been like pouring cold water on the family and on his defense team,” Villalba told The Associated Press on Thursday. “Nobody expected it, he had not said goodbye.”

Although Villalba said he had no evidence of any foul play but blamed the death on “the cruelty of the system” for keeping a 75-year-old behind bars for economic, not violent, crimes after judges refused to release him on bail.

”We had managed to nullify seven of the 10 counts he was accused of and even so he was still that dangerous person who could be fleeing Spain if he was released?" the lawyer said. “He was a world eminence, where could he hide?”

Spain's National Court on Monday ruled that McAfee should be extradited to the U.S. to face charges for evading more than $4 million in taxes in the fiscal years 2016 to 2018. The judge dropped seven of the 10 counts in the initial indictment.

Villalba said McAfee had learned about the ruling on Tuesday and that his death on Wednesday didn't come in the heat of the moment. He also said McAfee and the legal team had been preparing an appeal to avoid being extradited.

A penitentiary source told the AP that McAfee was sharing a cell in the Brians 2 jail where he had been put in preventive detention since he was arrested in October last year on a U.S. warrant, but that at the moment of his death he had been alone.

Prosecutors in Tennessee accused McAfee of failing to report income from promoting cryptocurrencies while he did consulting work, earnings made in speaking engagements and for selling the rights to his life story for a documentary. The criminal charges carried a prison sentence of up to 30 years.

The British-born entrepreneur led an eccentric life after selling his stake in the antivirus software company named after him in the early 1990s. He twice made long-shot runs for the U.S. presidency.

McAfee often professed his love for drugs and guns in public remarks. And some of his actions landed him in legal trouble beyond Tennessee, from Central America to the Caribbean. In 2012, he was sought for questioning in connection with the murder of his neighbor in Belize, but was never charged with a crime.