This paper presents a genetic algorithm for the location of distributed generation units, using the equations of power flow and energy balance between demanded power and generated power. The genetic algorithm is performed in the open-source programming language Python due to its current importance and the multiple libraries for data science. The genetic algorithm for distributed generation location is applied in a feeder circuit in the city of Arequipa