SAN FRANCISCO — The heroin needles, the pile of excrement between parked cars, the yellow soup oozing out of a large plastic bag by the curb and the stained, faux Persian carpet dumped on the corner.

It is a scene of detritus that might bring to mind any variety of developing-world squalor. But this is San Francisco, the capital of the nation’s technology industry, where a single span of Hyde Street hosts an open-air narcotics market by day and at night is occupied by the unsheltered and drug-addled slumped on the sidewalk.

There are many other streets like it, but by one measure it is the dirtiest block in the city.

Just a 15-minute walk away are the offices of Twitter and Uber, two companies that along with other nameplate technology giants have helped push the median price of a home in San Francisco well beyond a million dollars.

This dichotomy of street crime and world-changing technology, of luxury condominiums and grinding, persistent homelessness, and the dehumanizing effects for those forced to live on the streets provoke outrage among the city’s residents. For many who live here it is difficult to reconcile San Francisco’s liberal politics with the misery that surrounds them.

According to city statisticians, the 300 block of Hyde Street, a span about the length of a football field in the heart of the Tenderloin neighborhood, received 2,227 complaints about street and sidewalk cleanliness over the past decade, more than any other. It is an imperfect measurement — some blocks might be dirtier but have fewer calls — but residents on the 300 block say that they are not surprised by their ranking. The San Francisco bureau photographer, Jim Wilson, and I set out to measure the depth of deprivation on a single block. We returned a number of times, including a 12-hour visit, from 2 p.m. to 2 a.m. on a recent weekday. Walking around the neighborhood we saw the desperation of the mentally ill, the drug dependent and homeless, and heard from embittered residents who say it will take much more than a broom to clean up the city, long considered one of the United States’ beacons of urban beauty.

‘You Have to Hold Your Breath’

Human waste has become such a widespread problem in San Francisco that the city in September established a unit dedicated to removing it from the sidewalks. Rachel Gordon, a spokeswoman for the public works department, describes the new initiative as a “proactive human waste” unit.

At 8 a.m. on a recent morning, as mothers shepherded their children to school, we ran into Yolanda Warren, a receptionist who works around the corner from Hyde Street. The sidewalk in front of her office was stained with feces. The street smelled like a latrine.

“Some parts of the Tenderloin, you’re walking, and you smell it and you have to hold your breath,” Warren said.

At she does every morning, she hosed down the urine outside her office. The city has installed five portable bathrooms for the hundreds of unsheltered people in the Tenderloin but that has not stopped people from urinating and defecating in the streets.

“There are way too many people out here that don’t have homes,” Warren said.

Over the past five years the number of homeless people in San Francisco has remained relatively steady — around 4,400 — and the sidewalks of the Tenderloin have come to resemble a refugee camp.

The city has replaced more than 300 lampposts corroded by dog and human urine over the past three years, according to the San Francisco Public Utilities Commission. Replacing the poles became more urgent after a lamppost collapsed in 2015, crushing a car.

A more common danger are the thousands of heroin needles discarded by users.

The Public Works Department and a nonprofit organization in the Tenderloin picked up 100,000 needles from the streets over the past year. The Public Health Department, which has its own needle recovery program, has a more alarming figure: It retrieved 164,264 needles in August alone, both through a disposal program and through street cleanups.

Larry Gothberg, a building manager who has lived on Hyde Street since 1982, keeps a photographic record of the heroin users he sees shooting up on the streets. He swiped through a number of pictures on his phone showing users in a motionless stupor.

“We call it the heroin freeze,” Gothberg said. “They can stay that way for hours.”

‘Land of the Living Dead’

Hyde Street is in the heart of the Tenderloin, a neighborhood of aging, subsidized single-occupancy apartment buildings, Vietnamese and Thai restaurants, coin laundromats and organizations dedicated to helping the indigent. Studio apartments on Hyde Street go for around $1,500, according to Gothberg, cheap in a city where the median rent for apartments is $4,500.

A number of people we met on Hyde Street distinguished between the residents of the Tenderloin, many of them immigrant families, and those they called “street people” — the unsheltered drug users who congregate and camp along the sidewalks and the dealers who peddle crack cocaine, heroin and a variety of amphetamines.

Disputes among the street population are common and sometimes result in violence. At night bodies line the sidewalks.

“It’s like the land of the living dead,” said Adam Leising, a resident of Hyde Street.

We met Leising late one evening after he had finished a shift as a server at a restaurant. As we toured the neighborhood, past a man crumpled on the ground next to empty beer bottles and trash, Leising told us that the daily glimpses of desperation brought him to the brink of depression.

“We are the most advanced country in the world,” Leising said. “And that’s what people are having to live with here.”

Leising, who is the founder of the Lower Hyde Street Association, a nonprofit that holds cleanup activities on the street, feels that the city is not cracking down on the drug trade on the block because they do not want it to spread elsewhere.

“It’s obvious that it’s a containment zone,” Leising said. “These behaviors are not allowed in other neighborhoods.”

The Tenderloin police station posted on their Twitter feed that drug dealing “is the most significant issue impacting the quality of life.” So far this year, officers from the Tenderloin station house have made more than 3,000 arrests, including 424 for dealing drugs.

“This is one of our priority areas,” said Grace Gatpandan, a police spokeswoman said of the Tenderloin. But many feel they do not do enough. Gavin Newsom, a former mayor of San Francisco and the leading candidate for governor in next month’s election, told The San Francisco Chronicle editorial board last week that the city had reached the point of “enough is enough.”

“You can be too permissive and I happen to think we have crossed that threshold in this state — and not just in this city,” Newsom said. “You see it. It’s just disgraceful.”

‘We Know All of Them’

Mayor London Breed, who was elected in June, campaigned to clean up squalor.

Breed has announced plans to provide an additional 1,000 beds for the homeless over the next two years but she is also targeting a relatively small group of people living on the streets whom she says are beyond the point of assisting themselves. The concept of this involuntary removal is known as conservatorship. A law recently passed in Sacramento strengthens the city’s powers of conservatorship with a judge’s permission.

“There are about 100 to 150 people who are clearly mentally ill and who are cycling through the system and who need to be forced into conservatorship,” Breed said in an interview. “We know all of them.”

According to Breed’s office 12 percent of people who use the services of the San Francisco Department of Public Health account for 73 percent of the costs. The majority of these heavy users have medical, psychiatric and substance use issues, according to the department.

Breed has made unannounced inspections of neighborhoods, sometimes carrying a broom.

On a Saturday morning in September, she walked past a woman on Hyde Street slouched on the pavement and preparing to plunge a syringe into her hand.

“Put that away,” said a police officer accompanying the mayor. The Crack Tree

On a recent afternoon we dropped by a barbershop on Hyde Street.

Glenn Gustafik opened Mister Hyde two years ago to escape the high rents of downtown San Francisco, where he was quoted a $10,000 monthly rent for a similarly small space. Since opening on Hyde Street he has been engaged in a battle with drug users in the neighborhood who break the branches off a London plane tree in front of his shop and use the sticks to clean their crack pipes. This harvesting of twigs has killed the previous four trees, Gustafik said. At Gustafik’s request the city protected the fifth tree with wire mesh, the kind used in suburban areas to discourage hungry deer.

A Sisyphean Cleanup

Toward dusk and into the night the 300 block of Hyde becomes an impromptu food and flea market. A woman offered a bicycle for $15 one evening and bric-a-brac was laid out on the sidewalks. Many items for sale were incongruous: A man hawked six shrink-wrapped packets of raw steaks that he cradled precariously as he called out for buyers. No one asked where he got them.

At dawn crews from the city and private organizations arrive to pick up needles and trash. The city spends $70 million annually on street cleaning, well more than any other U.S. cities that were studied in a recent report.

But the sidewalks soon become crowded again and the litter accumulates.

Mario Montoya Jr. has spent the past three decades cleaning the streets as an employee of the city’s Public Works Department. Standing on a street corner as another city employee power-washed the sidewalk, Montoya described a Sisyphean cycle of cleanup and filth.

“By noon everybody is up and out,” Montoya said. “And here we go again.”