I have one problem with pythontex using TeXShop: after compiling it, I need to manually go to the terminal and call pythontex filename.pdf. Is it possible to avoid this and let TeXShop call pythontex?
I almost succeeded in running PythonTeX with this MWE:
\documentclass{beamer}
\usepackage{pythontex}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}
\usepackage[T1]{fontenc}
\begin{document}
\begin{frame}[fragile]{Partial Derivatives}
\begin{pycode}
from sympy import *
var("x")
functions = [sin(x), cos(x), tan(x)]
print(r"\begin{align*}")
for f in functions:
d = Derivative(f, x)
print(latex(d) + "&=" + latex(d.doit()) + r"\\")
print(r"\end{align*}")
\end{pycode}
\end{frame}
\end{document}
As I need XeLaTeX, my first adaptation of pythontex engine file in TeXShop was:
PATH=/Applications/anaconda/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/texbin
filename=$1
xelatex -8bit --file-line-error --synctex=1 $1
pythontex $1
My second adaptation to the engine template was:
PATH=/Applications/anaconda/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/texbin
filename=$1
pdfname = "${filename:r}.pdf"
xelatex -8bit --file-line-error --synctex=1 $1
pythontex $1
xelatex -8bit --file-line-error --synctex=1 $1
pythontex pdfname
xelatex -8bit --file-line-error --synctex=1 $1
I really do not know much about the language used in the engine files, I'm just trying my best educated guess based on the templates I saw.
Edit: I followed Allan Munn's answer but I have the same problem. The last part of log file looks like:
(./pythontex-files-test/test.pytxmcr) (./test.nav)
(./pythontex-files-test/test.pytxpyg) (./test.vrb
(./pythontex-files-test/py_default_default_0.stdout
(/usr/local/texlive/2015/texmf-dist/tex/latex/amsfonts/umsa.fd)
(/usr/local/texlive/2015/texmf-dist/tex/latex/amsfonts/umsb.fd))) [1]
(./test.aux) )
Output written on test.pdf (1 page).
SyncTeX written on test.synctex.gz.
Transcript written on test.log.
Traceback (most recent call last):
File "/usr/texbin/pythontex", line 50, in <module>
import pythontex2 as pythontex
File "/usr/local/texlive/2015/texmf-dist/scripts/pythontex/pythontex2.py", line 61, in <module>
from pygments.styles import get_all_styles
ImportError: No module named pygments.styles