The first line seems to correctly set up the temporary bash environment that cron starts, so as long as you have previously set up conda for your bash environment (conda init bash) then your temporary bash session should inherit that.
Would be grateful of someone more experienced in this than me would vet this for accuracy and caveats.
(and I cannot for the life of me remember where I read it)
If you wanted you could use a shebang at the top of your python script to specify the environment it should run in a la:
#!/home/username/anaconda/envs/envname/bin/python
This would allow you to decouple your bash scripts from your environments and keep them in the python file. The major downside here is that you have to use the relative path of the environment instead of the name. So if you were doing something like a dockerized deployment this might be annoying.
Apparently you could also use the conda run command, but I’ve seen odd things about it on the conda Github tracker that says its broken. Here is an example: #!/usr/bin/env conda run -n my_env python
I’m not sure what the threshold for it failing is, because on some scripts it has worked fine. There’s obviously some tipping point (maybe certain dependencies).