Chemistry - Which is anode and which is cathode?
Solution 1:
Regardless of the polarity, the electrode where oxidation takes place is the called the anode and therefore reduction must take place at the cathode. The electron flow from the anode to cathode is as shown in your top picture.
By way of an example, in an electrochemical cell, suppose that two beakers are connected by a salt bridge. In one beaker is a strip of zinc metal immersed in a $\ce{Zn(NO3)2}$ solution and in the other a strip of silver in $\ce{AgNO3}$ solution. The two metals are then connected by a wire and a current will flow. (The salt bridge supplies a return path so that the solutions remain electrically neutral). The redox of the Zn electrode is $-0.763$ V and that of the Ag $+0.799$ V. This means that electrons will flow from the zinc to the silver electrode. The zinc is oxidised to $\ce{Zn^{2+}}$ and the electrons are released into the metal and flow to the silver electrode through the wire. The zinc electrode is the anode and the silver the cathode.
Solution 2:
There is no completed electronic circuit in an electrochemical cell
In an electrochemical cell, the anode is the source of electrons to the external circuit and the cathode is the sink. The circuit of charge transport gets completed by ions traveling inside the cell. A solar cell is different from an electrochemical cell in that their is no net chemical reaction. In the solar cell, electrons flow in a closed circuit - round and round in the external circuit and through the device.
Designation of anode and cathode
So labeling the anode and the cathode relies on an analogy between a voltaic cell and a photovoltaic cell as a source of electrical work. It makes sense to use the direction of electron flow in the external circuit to define anode and cathode (electrons flow from anode to cathode in the external circuit). In the voltaic cell, there is no electron flow inside the cell (there is ion flow instead to balance charges). In the photovoltaic cell, electrons flow from junction to anode and holes flow from junction to cathode (or you could say electrons flow from cathode to junction).
Unfortunately, anode and cathode are named using different conventions depending on the type of device, see this overview (and beware that the current I sometimes goes in the same direction as the electrons and sometimes not, again depending on conventions).
Negative and positive electrode
The (+) and (-) designation is confusing even just for electrochemical cells. While the designation of anode and cathode is consistent for voltaic and electrolytic cells (i.e. using and charging a battery), the designation of (+) and (-) switches, so it is uncoupled from the direction the electrons flow through the external wire.
Direction of electron flow
For the photovoltaic cell, maybe this picture helps: Before light hits the cell, anode and cathode are neither negative nor positive. Once light hits the cell, the anode becomes negative because electrons are moving toward it from the junction, and the cathode becomes positive because electrons are jumping from it into holes coming from the junction. If you then attach an external consumer of electrical work, you can predict the direction of electron flow through the external circuit.