This study presents a master–slave methodology to solve the problem of optimally locating and sizing photovoltaic (PV) generation units in electrical networks. This problem is represented by means of a Mixed-Integer Nonlinear Programming (MINLP) model, whose objective function is to reduce the total annual operating costs of a network for a 20-year planning period. Such costs include (i) the costs of purchasing energy at the conventional generators (the main supply node in this particular case), (ii) the investment in the PV generation units, and (iii) their corresponding operation and maintenance costs. In the proposed master–slave method, the master stage uses the Discrete–Continuous version of the Crow Search Algorithm (DCCSA) to define the set of nodes where the PV generation units will be installed (location), as well as their nominal power (sizing), and the slave stage employs the successive approximation power flow technique to find the value of the objective function of each individual provided by the master stage. The numerical results obtained in the 33- and 69-node test systems demonstrated its applicability, efficiency, and robustness when compared to other methods reported in the specialized literature, such as the vortex search algorithm, the generalized normal distribution optimizer, and the particle swarm optimization algorithm. All simulations were performed in MATLAB using our own scripts.