pythontex - How to choose the version of Python used?

See the pythontex documentation (bottom of subsection 2.2 in v0.12?); it lists a number of options that pythontex.py accepts, including the following one, which allows you to specify the interpreter that pythontex should use:

--interpreter

This allows the interpreter for a given language to be specified. The argument should be in the form

--interpreter "<interpreter>:<command>, <interp>:<cmd>, ..."

where <interpreter> is python, ruby, etc., and <command> is the command for invoking the desired interpreter. The argument to --interpreter may also be in the form of a Python dictionary. The argument need not be enclosed in quotation marks if it contains no spaces.

For example, by default Python code is executed with whatever interpreter the python command invokes. But Python 3 could be specified using --interpreter python:python3 (many Linux distributions) or --interpreter "python:py -3" (Windows, with Python 3.3 installed so that the py wrapper is available).

Tags:

Python