3

I tried the PythonTeX package, and the output it produced contained question marks instead of running python code, what should i do ??

  • 3
    Welcome to TeX.sx! Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. Moreover, as I read it PythonTeX lets you execute python code, and putting the result back into the document. It is not meant to show the code itself, right? – mafp Apr 03 '13 at 23:48
  • 4
    I haven't used PythonTeX but I've used similar packages (SageTeX) which give the same ?? unless you process it in 3 stages: run latex on the document (the output will be the question marks you've seen) and a special file will be created (with sage it's a .sage file). Next, run the script/program on that special file. Finally, latex the document again. Question marks should be gone if the code was valid. I googled up this video on PythonTeX where the author mentions the 3 step process at the 9:30 mark. Have you done the 3 step process? – DJP Apr 04 '13 at 00:30
  • 3
    DJP is correct; PythonTeX's operation uses the same principle as SageTeX. You have to run LaTeX (this saves all the Python code in an auxiliary file), then run the PythonTeX script (pythontex2.py or pythontex3.py, depending on your Python version), and finally run LaTeX again (which brings in the output of the script). There are question marks/placeholders for any code output that is expected but not yet available, with corresponding warnings. – G. Poore Apr 04 '13 at 01:29
  • @DJP I guess that is the problem, i didn't know that i should run the python script, thank you – theatropos1994 Apr 04 '13 at 13:16
  • @DJP you should post this as answer, so this question won't remain "unanswered" – Tobias Kienzler Apr 11 '13 at 06:54

1 Answers1

2

Packages which call other programs, such as sagetex, python, gnuplot, or (as G. Poore confirms) PythonTeX require you to process the your document in a similar fashion: 1. (pdf)latex your document to create a special file (with sagetex it's a .sage file. 2. Process the special file with the program/script (Sage/Python/gnuplot) 3. (pdf)latex your document again.

After step 1 your output will have ?? marks where the computations/pictures are supposed to be. I suspect you didn't realize that 2 more steps of processing are necessary. As G. Poore indicates above your second step will be "run the PythonTeX script (pythontex2.py or pythontex3.py, depending on your Python version)". Depending on the package you might be able to streamline the process with a shell escape in your tex file or configuration of your IDE

DJP
  • 12,451