The gemara proves that a magosh couldn't be a sorcerer according
to Rav, because Rav holds that a one who learns from a magosh is deserving of death, and also that it is permitted to learn sorcery. My question is that perhaps it is only permitted to learn sorcery from a talmid chochom, but in fact Rav would hold that one who learns it from an actual sorcerer is deserving of death. How did the first talmid chochom to know sorcery learn it? Perhaps he first learned it and then became a talmid chochom, or perhaps it was the sorcerers who originally learned it from talmidei chachomim.
Thanks, and be well.
The SEFAS EMES asks your question, that perhaps it is only permitted to learn sorcery from a Talmid Chacham, and one who learns it from a sorcerer is indeed deserving of death. The Sefas Emes answers that it could be that since we find that it is permitted to learn sorcery (even if only from a Talmid Chacham), it is not proper to scorn a sorcerer and to say that one who learns from him is deserving of death.
The Sefas Emes offers a second answer, and explains that the Gemara's proof is from a previous verse which states, "You shall not learn [from the ways of the gentiles] to do [like their ways]," which implies that one may not learn from them in order to do like them, but one may learn from them in order to teach. This implies that one may even learn from a sorcerer.