0

The following commands are working fine in Python 3.x:

import numpy as np
M = np.array([[1,2,3],[4,5,6]])
D = np.diag([1,2,3])
M@D

But, when I use pythontex, I get an error with M@D. Do you know why?

error screenshot

MWE

\documentclass[a4paper]{book}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}
\usepackage{pythontex}
%%%%%%%%%%%%
\begin{document}

\begin{pyconsole}
import numpy as np
M = np.array([[1,2,3],[4,5,6]])
D = np.diag([1,2,3])
M@D
\end{pyconsole}

\end{document}

I typeset my .tex file with xelatex -8bit filename / pythontex filename / xelatex -8bit filename

  • Could be a missing \makeatletter - \makeatother or Python version problem. Without an MWE is difficult to say... – Rmano Oct 28 '19 at 6:51
  • My message contains now a MWE. – jowe_19 Oct 28 '19 at 10:14
  • I tried to add the option --interpreter python:python3 to pythontex, but it doesn't fix the issue (and I think that since the last version of Pythontex, the default interpreter is Python 3). – jowe_19 Oct 28 '19 at 10:27
  • This works fine for me with the latest pythontex. So we need to know more about the versions you have and how you run pythontex. – Andrew Swann Oct 28 '19 at 10:54
  • 1
    Thank you - some of this information should be edited in to your question. Anyway, it sounds like you need to check the paths and environment that TeXpad uses to call the compilation commands. – Andrew Swann Oct 29 '19 at 7:48
0

Finally, I fixed the issue by adding source ~/.zshrc at the beginning of the tpbuild script used by Texpad for typesetting. The PATH used by TexPad is now correct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.