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

10
  • Could be a missing \makeatletter - \makeatother or Python version problem. Without an MWE is difficult to say...
    – Rmano
    Commented Oct 28, 2019 at 6:51
  • My message contains now a MWE.
    – jowe_19
    Commented Oct 28, 2019 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
    Commented Oct 28, 2019 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. Commented Oct 28, 2019 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. Commented Oct 29, 2019 at 7:48

1 Answer 1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .