Skip to content

depythontex fails with Could not find command "py" #186

Description

@mfacorcoran

I'm having an issue running depythontex on a file compiled with pythontex

the file is compiled using

\usepackage[depythontex=true]{pythontex}

but when I try to depythontex the tex file I get

% depythontex wr140_rxte_swift_nicer.tex

  • DePythonTeX error:
    Could not find command "py" on line 509

I'm using

% depythontex --version
DePythonTeX 0.16

probably user error but I've tried to re-install and still getting the same error...

Activity

  1. gpoore commented on Jun 25, 2021

    @gpoore
    Owner

    Sometimes depythontex fails when a command is used inside of commands or environments that do something non-standard. This is largely a limitation of how LaTeX functions, but there are usually ways to work around it. Can you provide any information about what commands/environments are wrapping a \py command around line 509 of you document?

  2. mfacorcoran commented on Jun 25, 2021

    @mfacorcoran
    Author
  3. gpoore commented on Jun 25, 2021

    @gpoore
    Owner

    My guess is that deluxetable is doing some special processing that throws off the line numbering that depythontex expects. You might try switching from the \py command to the pysub environment, which should be able to work around this. Currently, deluxetable processes everything first, and then PythonTeX gets the \py commands. This works for normal PythonTeX functionality but not the additional requirements of depythontex. By switching to pysub, PythonTeX will receive everything before deluxetable and can process things first in a way that works with depythontex while maintaining LaTeX functionality.

    To use pysub, wrap the entire deluxetable in \begin{pysub}...\end{pysub} and then replace each \py with !. Something like this, similar to a Python format string but using !{...} for substitution fields:

    \begin{pysub}
    \begin{deluxetable}{lrl}
    \tabletypesize{\scriptsize}
    \tablecaption{Adopted Orbital and Stellar Parameters\label{tab:params}}
    \tablehead{\colhead{Parameter} & \colhead{Value} & \colhead{Reference or Comment}}
    \startdata
    Period (days)  &      !{period.value}$\pm0.17$  & T21   (from Table 3,  ``Adopted Fit'') \\
    eccentricity  &     !{'{0:.4f}'.format(eccen)} $\pm$   !{'{0:.4f}'.format(eccerr)}& T21   \\
    Time of Periastron Passage (MJD) &   !{'{0:.2f}'.format(t_tr.mjd)} $\pm$  !{'{0:.2f}'.format(t_oerr)}   & Best fit $T_{o}$ from T21     \\
    $\omega_{\mbox{WR}}$ (degrees) &     !{'{0:.2f}'.format(omega)} $\pm$ !{'{0:.2f}'.format(omegerr)}  & T21     \\
    $\Omega$ (degrees)  &   !{'{0:.2f}'.format(Omega)}   $\pm$ !{'{0:.2f}'.format(Omegerr)} & T21   \\
    $i$ (degrees)  &   !{'{0:.2f}'.format(inc)}  & T21    \\
    $a$ (AU) & !{'{0:.2f}'.format(sma.value)}$\pm$  !{'{0:.2f}'.format(smaerr.value)} & T21 \\
    $M_{WR}$ (\msun)   &     !{'{0:.2f}'.format(m1)} $\pm$    !{'{0:.2f}'.format(m1err)} & T21   \\
    $M_{O}$ (\msun)  &      !{'{0:.2f}'.format(m2)}  $\pm$    !{'{0:.2f}'.format(m2err)} & T21   \\
    $\dot{M}_{WR}$ ($10^{-6}$\msun~yr$^{-1}$) &  !{'{0:.1f}'.format(Mdotwr/1e-6)}  & \cite{2006MNRAS.372..801P} \\
    $\dot{M}_{O}$ ($10^{-6}$\msun~yr$^{-1}$) &  !{'{0:.1f}'.format(Mdoto/1e-6)}  &  \cite{2006MNRAS.372..801P} \\
    $V_{\infty, WR}$ (km~s$^{-1}$) & !{f'{Vwr:.0f}'}  &\cite{2001aap...376..460S} \\
    $V_{\infty, O}$ (km~s$^{-1}$) &  !{f'{Vo:.0f}'}  & \cite{2001aap...376..460S} \\
    $\eta$ & !{'{0:.2f}'.format((4.30e-5*2860)/(8.e-7*3100))} & $=(\dot{M}_{WR}V_{\infty, WR}$)/($\dot{M}_{O}V_{\infty, O}$)\\
    Adiabatic-Shock Opening Angle (degrees)\tablenotemark{a} & 41.3 &  \cite{2009ApJ...703...89G} equation (11) \\
    Radiative-Shock Opening Angle (degrees)\tablenotemark{a} & 31.7 & \cite{1996ApJ...469..729C} equation (28) \\
    WR-Shock Stand-off Distance\tablenotemark{b} & 0.876 & \cite{1996ApJ...469..729C} equation (27) \\
    Distance (pc)  &   !{'{0:.0f}'.format((D.to(u.pc)).value)}  & Gaia~DR2 \& T21 \\
    $v$ & $7.07$ & \cite{1984ApJ...281..789M} \\
    $b-v$ & $+0.27$ & \cite{1984ApJ...281..789M} \\
    $N_{H}$ ($10^{21}$~cm$^{-2})$ & 4.3 & Interstellar absorption column density
    \enddata
    \tablenotetext{a}{Theoretical asymptotic opening half-angle determined by $\eta$}
    \tablenotetext{b}{Fraction of binary separation determined by $\eta$}
    \end{deluxetable}
    \end{pysub}
  4. mfacorcoran commented on Jun 25, 2021

    @mfacorcoran
    Author

    Thanks for all the help Geoffrey. I evaluated the \py{} code by hand and replaced the code with the evaluated values which solved the deluxetable problem (there was another issue with a \py{} in a caption environment) and allowed me to depythontex without problem. I'll try the \pysub solution you proposed though and let you know how that works.

    Update - the \pysub solution works to solve the deluxtable environment issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions