If your python code is generating raw HTML or LaTeX then the results='asis' option will ensure that it’s passed straight into the document’s output stream
So you don't need init_printing, just a few modifications to your code:
```{python, results='asis'}
from sympy import *
x=symbols('x')
d=diff(sin(x)/cos(x), x)
print('$' + latex(d) + '$') # need to add '$' so it is recognized as MathJax
```