pythontex
pythontex copied to clipboard
Invalid escape sequences in python3.py
When compiling a file with pythontex I get messages about invalid escape sequences in python3.py. I am running the latest version from texlive. The output of pythontex --version gives
/usr/local/texlive/2023/texmf-dist/scripts/pythontex/pythontex3.py:549: SyntaxWarning: invalid escape sequence '\s'
msg = '''
/usr/local/texlive/2023/texmf-dist/scripts/pythontex/pythontex3.py:1810: SyntaxWarning: invalid escape sequence '\s'
errgobble = match('(\s*)', line).groups()[0]
/usr/local/texlive/2023/texmf-dist/scripts/pythontex/pythontex3.py:2075: SyntaxWarning: invalid escape sequence '\s'
errgobble = match('(\s*)', line).groups()[0]
PythonTeX 0.18
which already contains the errors.
The first instance should replace "\setpythontexworkingdir{<outputdir>}". by "\\setpythontexworkingdir{<outputdir>}". in the subsequent string.
The other two cases should probably replace '(\s*)' by a raw string r'(\s*)'.
I don't have experience of making changes on github, and have not be able to run pythontex in a way that uses a modified local version of python3.py, so have not be able to test these changes.
I can confirm the issue, but I also get another interesting bit.
/usr/local/texlive/2024/texmf-dist/scripts/pythontex/pythontex3.py:549: SyntaxWarning: invalid escape sequence '\s'
msg = '''
/usr/local/texlive/2024/texmf-dist/scripts/pythontex/pythontex3.py:1810: SyntaxWarning: invalid escape sequence '\s'
errgobble = match('(\s*)', line).groups()[0]
/usr/local/texlive/2024/texmf-dist/scripts/pythontex/pythontex3.py:2075: SyntaxWarning: invalid escape sequence '\s'
errgobble = match('(\s*)', line).groups()[0]
Traceback (most recent call last):
File "/Library/TeX/texbin/pythontex", line 55, in <module>
import pythontex3 as pythontex
File "/usr/local/texlive/2024/texmf-dist/scripts/pythontex/pythontex3.py", line 61, in <module>
from pygments.styles import get_all_styles
ModuleNotFoundError: No module named 'pygments'
made a pull request. Seems as if some prefix r missing.
By the way, seems to be a problem only from 3.12 or that like on.
This is fixed in the development version on GitHub and in the upcoming v0.19 release.