#1023586 texlive-extra-utils: pythontex won't find python (when on python3)

#1023586#5
Date:
2022-11-07 08:02:20 UTC
From:
To:
Hi.

When testing the use of pythontex in the context of auto-multiple-choice, I stumbled upon the fact that apparently pythontex won't find python:

This is PythonTeX 0.18
multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
  File "/usr/share/texlive/texmf-dist/scripts/pythontex/pythontex3.py", line 1569, in run_code
    proc = subprocess.Popen(exec_cmd, stdout=out_file, stderr=err_file)
  File "/usr/lib/python3.10/subprocess.py", line 971, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.10/subprocess.py", line 1847, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'python'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.10/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/usr/share/texlive/texmf-dist/scripts/pythontex/pythontex3.py", line 1583, in run_code
    proc = subprocess.Popen(exec_cmd_string, stdout=out_file, stderr=err_file)
  File "/usr/lib/python3.10/subprocess.py", line 971, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.10/subprocess.py", line 1847, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'cmd /C "@echo off & call python pythontex-files-amc-compiled/py_default_default.py & if errorlevel 1 exit 1"'
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/bin/pythontex", line 62, in <module>
    pythontex.main()
  File "/usr/share/texlive/texmf-dist/scripts/pythontex/pythontex3.py", line 2828, in main
    do_multiprocessing(data, temp_data, old_data, engine_dict)
  File "/usr/share/texlive/texmf-dist/scripts/pythontex/pythontex3.py", line 1390, in do_multiprocessing
    result = task.get()
  File "/usr/lib/python3.10/multiprocessing/pool.py", line 774, in get
    raise self._value
FileNotFoundError: [Errno 2] No such file or directory: 'cmd /C "@echo off & call python pythontex-files-amc-compiled/py_default_default.py & if errorlevel 1 exit 1"'


Indeed:
$ type python
bash: type: python: not found


This can be addressed by explicitely invoking with:
pythontex --interpreter python:python3

I guess this could probably be improved to avoid users having to figure out themselves.

Hope this helps,


##################################
minimal input file


##################################
other files

######################################
 List of ls-R files

#1023586#10
Date:
2022-11-07 10:07:25 UTC
From:
To:
Hi

something is **rather** strange on your system ...

That is Windows CMD code and nothing even remotely related to Linux.

Maybe also installing
	python-is-python3
or how the package name was.

Best

Norbert

#1023586#15
Date:
2022-11-07 11:38:36 UTC
From:
To:
Hi.

Norbert Preining <preining@logic.at> writes:

A Debian testing...

Well, I agree it looks fishy, but that's just the error log I
got... so... maybe it's just a wrong error message of some kind ?

That's it.

However, the description states "No packages may declare dependencies on
this package." ... does this include recommends or suggests ?

Thanks for the pointer and feedback anyway.

Best regards,

#1023586#20
Date:
2023-02-04 14:47:21 UTC
From:
To:
Am 07.11.2022 um 12:38 teilte Olivier Berger mit:
Hi Olivier,
In the Debian package the python interpreter is hard coded to python3 in
the pythontex scripts. Hence I do not really understand, what is going
on here. Could you provide a minimal input file for problem reproduction?

Hilmar

#1023586#25
Date:
2023-02-08 10:04:54 UTC
From:
To:
Hilmar Preuße <hille42@web.de> writes:

I'm afraid it's a bit hard for me to find time to prepare that, as I
initially used it inside an Auto-Multiple-Choice exams, which is a
complete mess of its own in terms of providing a minimal reproducible
set (see original report stack traces) :-/

Sorry.

Maybe that'll go away after some time in testing.

Thanks for caring.

Best regards,

#1023586#30
Date:
2026-05-10 09:13:21 UTC
From:
To:
Dear Maintainer,

I can confirm the bug is still there (I just stumbled upon it).

I could reproduce it with the (quasi)-minimal doc.tex, taken from the
README of https://github.com/gpoore/pythontex:
------------------------------------
\documentclass{article}

\usepackage{pythontex}

\newcommand{\pymultiply}[2]{\py{#1*#2}}

\begin{document}

\begin{pycode}
print("Python says ``Hello!''")
\end{pycode}

$8 \times 256 = \pymultiply{8}{256}$

\end{document}
------------------------------------


I then wrote the following script run.sh in the same directory:
------------------------------------ #! /bin/bash exec > run.log 2>&1 ls pdflatex -recorder -interaction=nonstopmode doc.tex pythontex doc.tex ------------------------------------ I chmoded it +x and ran it. I attach an archive of the resulting directory (minimal.tgz). Yours, J. Courant.