In a saucepan, combine sugar, flour, and cocoa powder; gradually whisk in milk until smooth.
Cook over medium heat, stirring constantly, until mixture comes to a boil and thickens. Cook for an additional 2 minutes after thickened.
Remove from heat and gradually stir about half of the hot mixture into the beaten egg yolks, then return to saucepan.
Bring back to a gentle boil, stir constantly and cook for 2 more minutes. Remove from heat and stir in butter and vanilla until smooth.
Pour mixture into the pre-baked pie crust and let it chill in the refrigerator for at least 4 hours.
Top with whipped cream before serving.