I am trying to use pythontex with Texmaker 5.0.2 (MikTeX 2.9.6637). I use an example code provided by overleaf.com (see below). On overleaf.com the example code does compile without any problems. When trying to compile with Quick Build (PdfLaTeX + Bib(la)tex + PdfLaTeX(x2) + View Pdf) I get an error message

error message in Texmaker Messages/Log

This is BibTeX, Version 0.99d (MiKTeX 2.9.6630 64-bit) The top-level
auxiliary file: main.aux I found no \citation commands---while reading file 
main.aux I found no \bibdata command---while reading file main.aux I found 
no \bibstyle command---while reading file main.aux (There were 3 error 
messages)

Process exited with error(s)

I have already added --enable-write18 to have -shell-escape

pdflatex -synctex=1 -interaction=nonstopmode --enable-write18 %.tex

EDIT: (partial solution thanks to @UlrikeFischer) I used tools >> Open Terminal and entered

pdflatex -shell-escape main
pythontex main
pdflatex -shell-escape main
main.pdf

the references in the pdf-file are working. But the pdf is not displayed in texmaker anymore.

overleaf.com example

\documentclass[12pt,a4paper]{scrartcl}
\usepackage[cm]{fullpage}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{tgpagella}
\usepackage{tgadventor}
\usepackage{inconsolata}

\usepackage{minted}
\usepackage{pythontex}

\usepackage{multicol}
\usepackage{hyperref}

\title{Using PythonTeX on Overleaf}
\author{Lian Tze Lim}
\date{}

\begin{document}

\maketitle

You need the \texttt{pythontex} package, and you need a custom \texttt{latexmkrc} file, e.g.~from \url{http://mirror.unl.edu/ctan/support/latexmk/example_rcfiles/pythontex-latexmkrc}.

Examples below are taken from \url{https://tug.org/tug2013/slides/Mertz-A_Gentle_Introduction_to_PythonTeX.pdf}

\begin{minted}{latex}
\py{2+2}
\end{minted}

\py{2+2}


\begin{minted}{latex}
Did you know that $2^{65} = \py{2**65}$?
\end{minted}

Did you know that $2^{65} = \py{2**65}$?

\begin{multicols}{2}

\begin{minted}{latex}
\begin{pycode}
lo, hi = 1, 6
print(r"\begin{tabular}{c|c}")
print(r"$m$ & $2^m$ \\ \hline")
for m in range(lo, hi + 1):
    print(r"%d & %d \\" % (m, 2**m))
print(r"\end{tabular}")
\end{pycode}
\end{minted}

\begin{pycode}
lo, hi = 1, 6
print(r"\begin{tabular}{c|c}")
print(r"$m$ & $2^m$ \\ \hline")
for m in range(lo, hi + 1):
    print(r"%d & %d \\" % (m, 2**m))
print(r"\end{tabular}")
\end{pycode}
\end{multicols}

Simulating interactive sessions:

\begin{pyconsole}
a = 1
b = 1
a+b
\end{pyconsole}

Some discussions above the code snippet above, and then continue\ldots

\begin{pyconsole}
c = a*2 + b
\end{pyconsole}

\end{document}
  • 2
    Your code doesn't contain anything related to bibliographies. So why do you call bibtex? – Ulrike Fischer May 14 at 14:25
  • It is my standard setting. Without pythontex it does not lead to any errors. Should I remove it? – MrYouMath May 14 at 14:27
  • 2
    I don't know if it is the source of your problems but I would never use "quick builds" and unnessary tools while investigating an error. They only make things more complicated. – Ulrike Fischer May 14 at 14:30
  • 2
    You must run pythontex yourfile and then pdflatex again. – Ulrike Fischer May 14 at 14:43
  • 2
    No, I don't use texmaker. I only know that the documentation says that you can add tools (xm1math.net/texmaker/doc.html#SECTION33). – Ulrike Fischer May 14 at 15:35

I found a solution based on the comment of @UlrikeFischer.

This is a solution for Texmaker.

First of all, you go to the menu User>>User Commands>>Edit User Commands. Here you select Command 1. Then you rename the Menu Item to PyTex (or something other that you like). Below is a command line click on the wizard button and add Pdf Viewer and hit the Ok button.

Now, the next thing that we have to do is to add the following commands into the Command line in front of the path that was input for your pdf viewer.

pdflatex -shell-escape %.tex|pythontex %.tex|pdflatex -shell-escape %.tex|

Finally, you can use this function as a way to build your documents. In order to run this, you will need to go to User >> User Commands >> PyTex (or what you entered). There is also a shortcut that you can use.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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