Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matplotlib (Python) totally broken on UCRT64 (at least) #22608

Open
2 of 6 tasks
angelog0 opened this issue Nov 21, 2024 · 5 comments
Open
2 of 6 tasks

Matplotlib (Python) totally broken on UCRT64 (at least) #22608

angelog0 opened this issue Nov 21, 2024 · 5 comments
Labels

Comments

@angelog0
Copy link

Description / Steps to reproduce the issue

Given:

$ cat plot_test.py
import matplotlib.pyplot as plt
import numpy as np

t = np.arange(0.0, 1.0 + 0.01, 0.01)
s = np.cos(2*2*np.pi*t)
plt.plot(t, s, '-', lw=2)

plt.xlabel('time (s)')
plt.ylabel('voltage (mV)')
plt.title('About as simple as it gets, folks')
plt.grid(True)

plt.axes().set_aspect('equal', 'datalim')


plt.show()

one gets

$ python plot_test.py
Traceback (most recent call last):
  File "C:/msys64/tmp/plot_test.py", line 1, in <module>
    import matplotlib.pyplot as plt
  File "C:/msys64/ucrt64/lib/python3.12/site-packages/matplotlib/__init__.py", line 159, in <module>
    from . import _api, _version, cbook, _docstring, rcsetup
  File "C:/msys64/ucrt64/lib/python3.12/site-packages/matplotlib/rcsetup.py", line 28, in <module>
    from matplotlib.colors import Colormap, is_color_like
  File "C:/msys64/ucrt64/lib/python3.12/site-packages/matplotlib/colors.py", line 57, in <module>
    from matplotlib import _api, _cm, cbook, scale
SyntaxError: source code string cannot contain null bytes

Expected behavior

It should open a window with a plot.

Actual behavior

It prints errors

Verification

Windows Version

MINGW64_NT-10.0-19045

MINGW environments affected

  • MINGW64
  • MINGW32
  • UCRT64
  • CLANG64
  • CLANGARM64

Are you willing to submit a PR?

No response

@angelog0 angelog0 added the bug label Nov 21, 2024
@podsvirov
Copy link
Collaborator

It's work for me as expected but only after commenting one line:

#plt.axes().set_aspect('equal', 'datalim')

Screenshot 2024-11-21 204239

@angelog0
Copy link
Author

angelog0 commented Nov 21, 2024

But all python scripts using matplotlib I have, worked until two months ago.. the above too... Now none work...

@lazka
Copy link
Member

lazka commented Nov 21, 2024

It's work for me as expected but only after commenting one line:

#plt.axes().set_aspect('equal', 'datalim')

same here

@angelog0
Copy link
Author

This is another example taken from here:

$ cat logistic_map.py
import numpy as np
import matplotlib.pyplot as plt

interval = (2.8, 4)  # start, end
accuracy = 0.0001
reps = 600  # number of repetitions
numtoplot = 200
lims = np.zeros(reps)

fig, biax = plt.subplots()
fig.set_size_inches(16, 9)

lims[0] = np.random.rand()
for r in np.arange(interval[0], interval[1], accuracy):
    for i in range(reps - 1):
        lims[i + 1] = r * lims[i] * (1 - lims[i])

    biax.plot([r] * numtoplot, lims[reps - numtoplot :], "b.", markersize=0.02)

biax.set(xlabel="r", ylabel="x", title="logistic map")
plt.show()

On WSL I have

$ python3 --version
Python 3.12.3

$ python3 logistic_map.py

and the image shows up.

On MSYS2/UCRT64:

$ python3 --version
Python 3.12.7

$ python3 logistic_map.py
Traceback (most recent call last):
  File "C:/msys64/home/angelo/programming/circle_3p/logistic_map.py", line 2, in <module>
    import matplotlib.pyplot as plt
  File "C:/msys64/ucrt64/lib/python3.12/site-packages/matplotlib/__init__.py", line 159, in <module>
    from . import _api, _version, cbook, _docstring, rcsetup
  File "C:/msys64/ucrt64/lib/python3.12/site-packages/matplotlib/rcsetup.py", line 28, in <module>
    from matplotlib.colors import Colormap, is_color_like
  File "C:/msys64/ucrt64/lib/python3.12/site-packages/matplotlib/colors.py", line 57, in <module>
    from matplotlib import _api, _cm, cbook, scale
SyntaxError: source code string cannot contain null bytes

@lazka
Copy link
Member

lazka commented Nov 21, 2024

Does pacman -Qkk mingw-w64-ucrt-x86_64-python-matplotlib give any errors? (checking if all files are unaltered)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants