John McAfee of antivirus software fame has arrived in London from the Dominican Republic, where he had been detained for several days with his wife and several others for entering the Caribbean nation with a cache of weapons on his yacht, his lawyer said Friday.

Authorities “asked him where he wanted to go, and he decided on London,” his attorney Candido Simon told Reuters.

News of his arrival in the UK came two days after McAfee, 73, the eponymous founder of the PC software security giant, said on Twitter that he was released “after four days of confinement” along with five other people, including his wife, Janice.

“I was well treated. My superiors were friendly and helpful. In spite of the helpful circumstances, we’ve decided to move on,” the British-born tech guru said in a tweet Wednesday.

After Dominican authorities ensured that the US had no active legal cases or extradition requests for McAfee, they allowed him to choose where he wanted to go, Simon said.

McAfee has been sought by US tax authorities since January 2012, when he announced that he had fled the country and “living in exile” on a boat because of felony charges handed down by the Internal Revenue Service.

A spokesman for the IRS told The Post on Friday that he could not release any information about the case, as per policy.

McAfee — who is seeking the Libertarian Party’s nomination for US president in 2020 — asked his Twitter followers on Friday whether he should also campaign to be British prime minister.

“Can a person run for, and be, President of the United States and Prime Minister of Great Britain simultaneously? Yes. Absolutely. Without question. But I believe I am one of the few people still alive who could qualify for the combined position,” he tweeted.

Earlier this week, McAfee docked his yacht, Great Mystery, in Puerto Plata, a province on the DR’s Atlantic north coast, where the weapons and ammo stash was seized, Reuters reported.

Customs officials said they found pistols, a shotgun and bars of suspected silver on the yacht.

While in custody, McAfee retweeted a photo posted by his wife of himself sitting shirtless in a cell.

“@theemrsmcafee insisted I looked better in this jailhouse photo since I was smiling. Janice was incarcerated in the cellblock next door at the same time. She just forgot how to properly smuggle phones,” he wrote.

“My crime is not filing tax returns – not a crime. The rest is propaganda by the U.S. government to silence me. My voice is the voice of dissent. If I am silenced, dissent itself will be next,” he wrote in a July 19 tweet.

“The CIA has attempted to collect us. We are at sea now and will report more soon. I will continue to be dark for the next few days,” he said in another tweet, which included a photograph of himself and a woman brandishing rifles.

On July 22, he wrote that they had been “at sea 4 and a half in rough weather. Nearing port. All is well. Will be back in the saddle shortly.”

McAfee said he couldn’t wait to “get off of this God forsaken boat that lost air conditioning and water 18 hours into the trip. None of us have bathed for 5 days.”

His Twitter account was later taken over by his campaign manager Rob Benedicto Pacifico Juan Maria Loggia-Ramirez, who wrote: “If John misses his next check-in, events will be set into motion that I cannot prevent once they have begun.

“John has secreted data with individuals across the world. I know neither their identities or locations. They will release their payloads if John goes missing.”

McAfee said in a video earlier this year that he was charged for “using cryptocurrencies in criminal acts” by Tennessee authorities, according to bitcoin.com.

“I am running my campaign in exile on this boat for the duration — I will not allow them to imprison me and shut my voice down, which they will do immediately — Why? I am a flight risk. Obviously, I am in flight,” McAfee said in the video.

The cybersecurity pioneer also boasted in a Jan. 3 tweet that he had not “filed a tax return for 8 years,” saying “taxation is illegal” and that his “net income is negative.”

At the peak of his wealth, McAfee’s net worth topped $100 million – but he reportedly lost the bulk of his fortune during the global financial crisis in 2009.

He then liquidated his assets and moved to Belize, where he surrounded himself with a harem of young women – many of whom moved in with him at his heavily fortified beachfront compound on Ambergris Caye.

In 2012, Belize police said McAfee was a “person of interest” in the murder of a neighbor. He told the news outlet Wired in November of that year that he was forced into hiding because local authorities were trying to kill him.

Prime Minister Dean Barrow dismissed the allegations, describing McAfee as “extremely paranoid — even bonkers.”

McAfee was later arrested in Guatemala, where he sought political asylum but was charged with entering the country illegally. He was hospitalized for suspected heart attacks, which he later claimed he faked to avoid being handed over to police in Belize.

On Dec. 21, 2012, Guatemalan authorities deported him to the US, where he reportedly met Janice, who solicited him as a prostitute in South Beach, Florida.

The couple have lived in constant fear of his assassination by agents of the Belize government, according to a Newsweek report.

McAfee sold his famous anti-virus software company, which he founded in 1987, in 1994 for about $75 million.