A possible alternative reason is that you are using some kind of sharing solution (for example, docker), where several virtual environments see the same home directory.
Gpg starts the daemon when it is first run, if it is not already running, and contacts it on ~/.gnupg/S.gpg-agent . It is possible that several gpg agents from different environments see the same socket, and therefore they experience incompatibility. Solution: kill the unnecessary gpg-agent process.
source share