Drush contrib modules not available if executed externally
The solution is to pass the environment variable $HOME to check_output, in this case /home/admin:

check_output("drush -l example.com -r /var/www/my/example/site/ entity-read node", shell=True, env={'HOME': "/home/admin"})


This force the /home/admin/.drush directory to be read. If everything is fine this command:

drush ev 'print(drush_server_home());'


should return /home/admin. If drush_server_home() returns an empty string, contrib modules installed inside .drush on home directory will not be available.

Ensure to install contrib modules with the same user controlling the /home/admin directory.

Read the documentation of the language you're using to pass the $HOME variable on command execution.