That’s kind of what we do today for pretty much everything. Most of the population on the planet doesn’t live near oil rigs, refineries, solar farms, power plants or wind. In fact most of the population doesn’t live near where we produce our food or most of the things we need for survival.
EU has enough areas with sparse population and not that much nature which also are south enough to have it work out well with solar panels of the current generations.
And besides that even most EU countries have enough places in them to still put a lot of solar panels without much issues and/or replacing fields.
going as far as North Africa is a bit too far to be convenient for power transport
How does that work out in cost per kWh? Profitable operation anywhere close?
Crisis relief (as suggested by jmward01 here) may be another matter, but setting up the ability to do this on scale, and maintaining it, can't be anything like easy economically.
The Desertec project could have turned a relatively small patch of Libyan desert into a solar farm that could supply all of Europe's electricity except that politics makes it impossible.
the issue is less the transport distances but changes in "from where to where" sometimes needing some extensions/improvements to the power grid. Through commonly in ways which anyway make sense and all pretty much "standard" solutions well understood. Through there are some more complicated exceptions to that.
EDIT: "distances we speak about" assumed less many local less dense populate/suitable spots across the EU, not a mega project like a energy pipeline from North Afrika.