Bug 1906363 - sympy.preview uses png codec removed from pyglet
Summary: sympy.preview uses png codec removed from pyglet
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: sympy
Version: 33
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Jerry James
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On: 1906512
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-12-10 11:38 UTC by Tomáš Raček
Modified: 2020-12-22 01:28 UTC (History)
6 users (show)

Fixed In Version: sympy-1.7.1-1.fc33
Clone Of:
Environment:
Last Closed: 2020-12-22 01:28:35 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Tomáš Raček 2020-12-10 11:38:56 UTC
Description of problem:

sympy.preview('x**2')

results in:

ModuleNotFoundError: No module named 'pyglet.image.codecs.png'

I guess it is caused by explicitly removing the png codec from the python-pyglet package:

https://src.fedoraproject.org/rpms/python-pyglet/blob/master/f/python-pyglet.spec#_96

Comment 1 Miro Hrončok 2020-12-10 17:30:39 UTC
First of all, there might be some latex dependency missing?

>>> import sympy
>>> sympy.preview('x**2')
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/sympy/printing/preview.py", line 252, in preview
    _check_output_no_window(
  File "/usr/lib/python3.9/site-packages/sympy/printing/preview.py", line 27, in _check_output_no_window
    return check_output(*args, creationflags=creation_flag, **kwargs)
  File "/usr/lib64/python3.9/subprocess.py", line 420, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/lib64/python3.9/subprocess.py", line 524, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['latex', '-halt-on-error', '-interaction=nonstopmode', 'texput.tex']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.9/site-packages/sympy/printing/preview.py", line 258, in preview
    raise RuntimeError(
RuntimeError: 'latex' exited abnormally with the following output:
b"This is pdfTeX, Version 3.14159265-2.6-1.40.21 (TeX Live 2020) (preloaded format=latex)\n restricted \\write18 enabled.\nentering extended mode\n(./texput.tex\nLaTeX2e <2020-02-02> patch level 5\nL3 programming layer <2020-04-06>\n\n! LaTeX Error: File `standalone.cls' not found.\n\nType X to quit or <RETURN> to proceed,\nor enter new name. (Default extension: cls)\n\nEnter file name: \n! Emergency stop.\n<read *> \n         \nl.2 ^^M\n       \nNo pages of output.\nTranscript written on texput.log.\n"


After $ dnf install 'tex(standalone.cls)' 'tex(euler.sty)' I can reproduce the problem:

$ python3 -c 'import sympy; sympy.preview("x**2")'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.9/site-packages/sympy/printing/preview.py", line 328, in preview
    return _run_pyglet(join(workdir, src), fmt=output)
  File "/usr/lib/python3.9/site-packages/sympy/printing/preview.py", line 35, in _run_pyglet
    from pyglet.image.codecs.png import PNGImageDecoder
ModuleNotFoundError: No module named 'pyglet.image.codecs.png'


When I hot-patch /usr/lib/python3.9/site-packages/sympy/printing/preview.py to use `from pyglet.image.codecs.pil import PILImageDecoder`, it works.

Comment 2 Jerry James 2020-12-10 17:59:27 UTC
Miro, thank you once again!  If we're ever in the same place at the same time, I owe you at least one drink. :-)

Comment 3 Fedora Update System 2020-12-10 21:30:27 UTC
FEDORA-2020-d312b367e4 has been submitted as an update to Fedora 33. https://bodhi.fedoraproject.org/updates/FEDORA-2020-d312b367e4

Comment 4 Fedora Update System 2020-12-11 00:59:44 UTC
FEDORA-2020-d312b367e4 has been pushed to the Fedora 33 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2020-d312b367e4`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2020-d312b367e4

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 5 Fedora Update System 2020-12-13 03:51:58 UTC
FEDORA-2020-d312b367e4 has been submitted as an update to Fedora 33. https://bodhi.fedoraproject.org/updates/FEDORA-2020-d312b367e4

Comment 6 Fedora Update System 2020-12-14 01:20:02 UTC
FEDORA-2020-d312b367e4 has been pushed to the Fedora 33 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2020-d312b367e4`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2020-d312b367e4

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 7 Petr Viktorin (pviktori) 2020-12-14 08:55:12 UTC
Indeed, I removed the png codec.
Upstream doesn't always install with the more performant PIL, but in Fedora we do. On the other hand, in Fedora there are bundling issues with PyPNG.

As the pyglet docs say[0], forcing a specific encoder is "not recommended unless your application has to work around specific deficiences in an operating system decoder." Are there any?

[0] https://pyglet.readthedocs.io/en/latest/programming_guide/image.html?highlight=PNGImageDecoder#loading-an-image

Comment 8 Jerry James 2020-12-14 16:23:43 UTC
No, and thank you for the updated patch.  I will contact upstream about making this change.

Comment 9 Fedora Update System 2020-12-22 01:28:35 UTC
FEDORA-2020-d312b367e4 has been pushed to the Fedora 33 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.