Calling a python script from custom wordpress rest api returns null

Thanks @JacobPeattie. I realize now after going through a few more articles that the problem was indeed not with wordpress but php and i was looking at the wrong place. The solution I found, I will write it down here just in case:

putenv('PYTHONPATH=C:\xampp\htdocs\mil\mypython\venv\Lib\site-packages');

The problem was indeed with php. I found the answer only after removing wordpress from the search query.