# How to configure Texstudio to use PythonTeX? [closed]

I learned how to add User commands to TeXstudio here: http://texstudio.sourceforge.net/manual/current/usermanual_en.html

In particular, for PythonTeX, I added the following command:

Then, I formed my build and view like so:

txs:///pdflatex | txs:///pythontex | txs:///pdflatex | txs:///biber | txs:///pdflatex | txs:///view-pdf-internal


I have confirmed that pythontex.exe is known to the system, by simply running the command in a console and noting the following output:

usage: pythontex.py [-h] [--version] [--encoding ENCODING]
[--error-exit-code {true,false}] [--runall [{true,false}]
| --rerun {never,modified,errors,warnings,always}]
[--hashdependencies [{true,false}]] [-j N] [-v]
[--interpreter INTERPRETER]
[--debug [<family>:<session>:<restart>] | --interactive
[<family>:<session>:<restart>]]
TEXNAME
pythontex.py: error: too few arguments
C:\texlive\2016\bin\win32\runscript.tlu:679: command failed with exit code 2:
python.exe c:\texlive\2016\texmf-dist\scripts\pythontex\pythontex.py


So, I decided to try my setup out on a simple document:

\documentclass[12pt,letterpaper]{article}
\usepackage{pythontex}

\begin{document}

\begin{pycode}
print(r'\begin{center}')
print(r'\textit{A message from Python!}')
print(r'\end{center}')
\end{pycode}

\end{document}


When I hit the build and view button though, everything hangs, and the log displays the following errors (line numbers correspond to the file pythontex.sty):

line 284: Use of \@xs@StrSubstitute@@ doesn't match its definition. \StrSubstitute{\pytx@jobname}{"}{}
line 284: Use of \\lstinline doesn't match its definition. \StrSubstitute{\pytx@jobname}{"}{}
line 284: Undefined control sequence. \StrSubstitute{\pytx@jobname}{"}{}
line 284: Undefined control sequence. \StrSubstitute{\pytx@jobname}{"}{}
line 284: Undefined control sequence. \StrSubstitute{\pytx@jobname}{"}{}
line 284: Undefined control sequence. \StrSubstitute{\pytx@jobname}{"}{}
line 284: Undefined control sequence. \StrSubstitute{\pytx@jobname}{"}{}
line 284: Undefined control sequence. \StrSubstitute{\pytx@jobname}{"}{}
line 284: Use of \@ doesn't match its definition. \StrSubstitute{\pytx@jobname}{"}{}


What's going wrong?

## closed as off-topic by Troy, Phelype Oleinik, TeXnician, Bobyandbob, Stefan PinnowAug 25 '18 at 7:20

• This question does not fall within the scope of TeX, LaTeX or related typesetting systems as defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

• Works fine for me. Is it only if you compile from the editor or form the console too? – TeXnician Jun 3 '17 at 6:21
• @TeXnician Does it work fine for you from within TeXstudio? I have only tried to compile from the editor, not the console. – user89 Jun 3 '17 at 7:14
• I have tried from within the console and from TeXstudio. It works. – TeXnician Jun 3 '17 at 7:17
• @TeXnician could I see how you have set up things in your editor (assuming it is TeXstudio?) – user89 Jun 3 '17 at 20:47
• I'm voting to close this question as solved in comments – Troy Aug 24 '18 at 23:45