The short answer
For most carpets, an enzyme cleaner is the best choice for human feces. Remove the solids first, blot instead of rubbing, apply the enzyme cleaner, and rinse with cool water. Wear gloves the whole time, because human waste can carry germs that make people sick.
Protect yourself and others first
Human feces can carry bacteria, viruses, and parasites. Put on disposable gloves, keep children and pets out of the area, and ventilate the room. If someone in the home has diarrhea or a stomach illness, take extra care with hygiene and with any cleaning tools you use.
Remove the solids and bag them
Lift solid waste with paper towels or a disposable scoop, working from the outside in. Seal the waste and the towels in a bag. Do not flush paper towels or anything else that may clog the toilet, and do not rub the area, since that can spread the mess.
Choose an enzyme cleaner
Enzyme cleaners break down protein and other organic matter, which is what human waste is made of. Look for a product labeled for carpet and for organic stains and odor. Apply it sparingly, let it sit for the time on the label, and keep the area damp while it works.
Baking soda and mild dish soap can help with some fresh stains. Avoid bleach as a shortcut. It can damage colored carpet, and it must never be mixed with ammonia or vinegar.
Test a hidden spot
Test the enzyme cleaner on a hidden area first, then check for color or fiber changes once it has dried. Wool and other natural fibers need extra care.
Blot, rinse, and dry
Blot the cleaner away after its dwell time, then rinse with cool water, since heat can set protein-based stains. Dry the carpet with towels and a fan, and keep people and pets off the area until it is fully dry. For the full sequence of steps, see how to clean up poop on carpet.
Clean up the items that touched the mess
Launder any washable clothing or linens that came into contact with the waste, using hot water and following the care label. Wash your hands thoroughly when you finish. Disinfect hard surfaces and tools with a product whose label suits that surface.
Disinfecting the carpet
For the question does steam cleaning carpet kill bacteria, the honest answer is that steam alone may not reliably kill germs in carpet. If you want to disinfect, look for a product whose label says it is safe for carpet or soft surfaces, and follow the directions for how long it should stay wet. Keep ventilation running while you work.
When to call a professional
Call a carpet cleaner for a large area, for repeated accidents, or when the mess has soaked through to the pad. Professionals may be able to clean and extract more thoroughly, and they can judge whether the padding needs replacing. Ask about their method before they start. For a broader look at cost and value, see is hiring a professional carpet cleaner worth it.
If vomit is also part of the cleanup, the guide on what is the best way to remove vomit stains from carpets takes a similar approach.