Executar um exemplo simples com PythonTeX falha

Executar um exemplo simples com PythonTeX falha

Usando a versão 0.12 beta do PythonTeX, estou tentando compilar o seguinte exemplo:

\documentclass[12pt]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{pythontex}

\begin{document}

\py{2+2}

\end{document}

Eu corro pdflatexno arquivo e, ao executar pythontexno arquivo, recebo o seguinte erro:

C:\Users\Uwe\Documents\python\Scripts\pythontex>pythontex pythntx1
This is PythonTeX v0.12beta
Traceback (most recent call last):
  File "c:/texlive/2013/texmf-dist/scripts/pythontex/pythontex.py", line 48, in
<module>
    pythontex.main()
  File "c:\texlive\2013\texmf-dist\scripts\pythontex\pythontex2.py", line 2125,
in main
    do_multiprocessing(data, temp_data, old_data, engine_dict)
  File "c:\texlive\2013\texmf-dist\scripts\pythontex\pythontex2.py", line 1055,
in do_multiprocessing
    result = task.get()
  File "C:\Python27\lib\multiprocessing\pool.py", line 522, in get
    raise self._value
TypeError: must be string without null bytes or None, not str
C:\texlive\2013\bin\win32\runscript.tlu:596: command failed with exit code 1:

É um bug na versão beta ou estou fazendo algo errado?

EDIT: As primeiras seis linhas do

Aqui estão as primeiras seis linhas de pythntx1.pytxcode:

=>PYTHONTEX#py#default#default#0#i####8#
2+2
=>PYTHONTEX:SETTINGS#
version=v0.12beta
outputdir=pythontex-files-pythntx1
workingdir=pythontex-files-pythntx1

A execução do código agora traz um erro diferente:

C:\Users\Uwe\Documents\python\Scripts\pythontex>pdflatex pythntx1.tex
This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013/W32TeX)
 restricted \write18 enabled.
entering extended mode
(./pythntx1.tex
LaTeX2e <2011/06/27>
Babel <3.9f> and hyphenation patterns for 78 languages loaded.
(c:/texlive/2013/texmf-dist/tex/latex/koma-script/scrartcl.cls
Document Class: scrartcl 2012/07/29 v3.11b KOMA-Script document class (article)

(c:/texlive/2013/texmf-dist/tex/latex/koma-script/scrkbase.sty
(c:/texlive/2013/texmf-dist/tex/latex/koma-script/scrbase.sty
(c:/texlive/2013/texmf-dist/tex/latex/graphics/keyval.sty)
(c:/texlive/2013/texmf-dist/tex/latex/koma-script/scrlfile.sty
Package scrlfile, 2012/06/15 v3.12 KOMA-Script package (loading files)
                  Copyright (C) Markus Kohm

))) (c:/texlive/2013/texmf-dist/tex/latex/koma-script/tocbasic.sty)
(c:/texlive/2013/texmf-dist/tex/latex/koma-script/scrsize12pt.clo)
(c:/texlive/2013/texmf-dist/tex/latex/koma-script/typearea.sty
Package typearea, 2012/07/29 v3.11b KOMA-Script package (type area)
                  Copyright (C) Frank Neukam, 1992-1994
                  Copyright (C) Markus Kohm, 1994-

)) (c:/texlive/2013/texmf-dist/tex/latex/base/fontenc.sty
(c:/texlive/2013/texmf-dist/tex/latex/base/t1enc.def))
(c:/texlive/2013/texmf-dist/tex/latex/base/inputenc.sty
(c:/texlive/2013/texmf-dist/tex/latex/base/utf8.def
(c:/texlive/2013/texmf-dist/tex/latex/base/t1enc.dfu)
(c:/texlive/2013/texmf-dist/tex/latex/base/ot1enc.dfu)
(c:/texlive/2013/texmf-dist/tex/latex/base/omsenc.dfu)))
(c:/texlive/2013/texmf-dist/tex/latex/pythontex/pythontex.sty
(c:/texlive/2013/texmf-dist/tex/latex/fancyvrb/fancyvrb.sty
Style option: `fancyvrb' v2.7a, with DG/SPQR fixes, and firstline=lastline fix
<2008/02/07> (tvz)) (c:/texlive/2013/texmf-dist/tex/latex/etex-pkg/etex.sty)
(c:/texlive/2013/texmf-dist/tex/latex/etoolbox/etoolbox.sty)
(c:/texlive/2013/texmf-dist/tex/generic/xstring/xstring.sty
(c:/texlive/2013/texmf-dist/tex/generic/xstring/xstring.tex))
(c:/texlive/2013/texmf-dist/tex/latex/pgfopts/pgfopts.sty
(c:/texlive/2013/texmf-dist/tex/latex/pgf/utilities/pgfkeys.sty
(c:/texlive/2013/texmf-dist/tex/generic/pgf/utilities/pgfkeys.code.tex
(c:/texlive/2013/texmf-dist/tex/generic/pgf/utilities/pgfkeysfiltered.code.tex)
))) (c:/texlive/2013/texmf-dist/tex/latex/caption/newfloat.sty)
(c:/texlive/2013/texmf-dist/tex/latex/upquote/upquote.sty
(c:/texlive/2013/texmf-dist/tex/latex/base/textcomp.sty
(c:/texlive/2013/texmf-dist/tex/latex/base/ts1enc.def
(c:/texlive/2013/texmf-dist/tex/latex/base/ts1enc.dfu))))) (./pythntx1.aux)
(c:/texlive/2013/texmf-dist/tex/latex/base/ts1cmr.fd)
(c:/texlive/2013/texmf-dist/tex/latex/xcolor/xcolor.sty
(c:/texlive/2013/texmf-dist/tex/latex/latexconfig/color.cfg)
(c:/texlive/2013/texmf-dist/tex/latex/pdftex-def/pdftex.def
(c:/texlive/2013/texmf-dist/tex/generic/oberdiek/infwarerr.sty)
(c:/texlive/2013/texmf-dist/tex/generic/oberdiek/ltxcmds.sty)
(c:/texlive/2013/texmf-dist/tex/context/base/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
)))

Package PythonTeX Warning: Missing autoprint content on input line 8.

[1{c:/texlive/2013/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
(./pythntx1.aux) ){c:/texlive/2013/texmf-dist/fonts/enc/dvips/cm-super/cm-super
-t1.enc}<c:/texlive/2013/texmf-dist/fonts/type1/public/cm-super/sfbx1200.pfb><c
:/texlive/2013/texmf-dist/fonts/type1/public/cm-super/sfrm1200.pfb>
Output written on pythntx1.pdf (1 page, 4786 bytes).
Transcript written on pythntx1.log.

C:\Users\Uwe\Documents\python\Scripts\pythontex>pythontex pythntx1
Traceback (most recent call last):
  File "c:/texlive/2013/texmf-dist/scripts/pythontex/pythontex.py", line 41, in
<module>
    import pythontex2 as pythontex
  File "c:\texlive\2013\texmf-dist\scripts\pythontex\pythontex2.py", line 970
    engine_dict[input_family].extension,
              ^
SyntaxError: invalid syntax
C:\texlive\2013\bin\win32\runscript.tlu:596: command failed with exit code 1:
python.exe c:/texlive/2013/texmf-dist/scripts/pythontex/pythontex.py pythntx1

EDITAR 20130716:

Depois de corrigir a vírgula na linha 969 eu recebo

C:\Users\Uwe\Documents\python\Scripts\pythontex>pythontex pythntx1
This is PythonTeX v0.12beta
Traceback (most recent call last):
  File "c:/texlive/2013/texmf-dist/scripts/pythontex/pythontex.py", line 48, in
<module>
    pythontex.main()
  File "c:\texlive\2013\texmf-dist\scripts\pythontex\pythontex2.py", line 2125,
in main
    do_multiprocessing(data, temp_data, old_data, engine_dict)
  File "c:\texlive\2013\texmf-dist\scripts\pythontex\pythontex2.py", line 976, i
n do_multiprocessing
    keeptemps, hashdependencies)
  File "c:\texlive\2013\texmf-dist\scripts\pythontex\pythontex2.py", line 1203,
in run_code
    proc = subprocess.Popen(exec_cmd, stdout=out_file, stderr=err_file)
  File "C:\Python27\lib\subprocess.py", line 679, in __init__
    errread, errwrite)
  File "C:\Python27\lib\subprocess.py", line 893, in _execute_child
    startupinfo)
TypeError: must be string without null bytes or None, not str
C:\texlive\2013\bin\win32\runscript.tlu:596: command failed with exit code 1:
python.exe c:/texlive/2013/texmf-dist/scripts/pythontex/pythontex.py pythntx1

EDITAR 20130716:

Após atualizar para Python 2.7.5, recebo agora:

Upgraded to Python 2.7.5. The old error is gone, but_
pythontex pythntx1
This is PythonTeX v0.12beta

----  Messages for py:default:default  ----
* PythonTeX notice
    1 message(s) could not be classified
    Based on the return code, they were interpreted as errors
* PythonTeX stderr - unknown on line ??:
  python: can't open file '<outputdir>\py_default_default.py': [Errno 2] No such
 file or directory

--------------------------------------------------
PythonTeX:  pythntx1 - 1 error(s), 0 warning(s)

C:\texlive\2013\bin\win32\runscript.tlu:596: command failed with exit code 1:
python.exe c:/texlive/2013/texmf-dist/scripts/pythontex/pythontex.py pythntx1

Responder1

PythonTeX v0.12beta funciona com Python 2.7.3 e posterior, mas não com Python 2.7.2 e anterior. Isto se deve às mudanças introduzidas em 2.7.3. Tentarei fazer a versão final 0.12 funcionar com todas as versões do Python 2.7.

Fiz algumas experiências adicionais com Python 2.7.2 e localizei a origem final do problema. subprocess.Popen()não era o problema. Em vez de,shlex.split() não suportava entrada Unicodeantes do Python 2.7.3.

Editar 27/08/2013:PythonTeX v0.12 detecta versões do Python anteriores à 2.7.3 e contorna o problema.

informação relacionada