Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite1e1360

Browse files
ksundenQuLogic
authored andcommitted
Backport PR#30394: ENH: Gracefully handle python-build-standalone ImportError with Tk
1 parente70262b commite1e1360

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

‎lib/matplotlib/backends/_backend_tk.py‎

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,36 @@
2222
TimerBase,ToolContainerBase,cursors,_Mode,MouseButton,
2323
CloseEvent,KeyEvent,LocationEvent,MouseEvent,ResizeEvent)
2424
frommatplotlib._pylab_helpersimportGcf
25-
from .import_tkagg
26-
from ._tkaggimportTK_PHOTO_COMPOSITE_OVERLAY,TK_PHOTO_COMPOSITE_SET
25+
26+
try:
27+
from .import_tkagg
28+
from ._tkaggimportTK_PHOTO_COMPOSITE_OVERLAY,TK_PHOTO_COMPOSITE_SET
29+
exceptImportErrorase:
30+
# catch incompatibility of python-build-standalone with Tk
31+
cause1=getattr(e,'__cause__',None)
32+
cause2=getattr(cause1,'__cause__',None)
33+
if (isinstance(cause1,ImportError)and
34+
isinstance(cause2,AttributeError)and
35+
"'_tkinter' has no attribute '__file__'"instr(cause2)):
36+
37+
is_uv_python="/uv/python"in (os.path.realpath(sys.executable))
38+
ifis_uv_python:
39+
raiseImportError(
40+
"Failed to import tkagg backend. You appear to be using an outdated "
41+
"version of uv's managed Python distribution which is not compatible "
42+
"with Tk. Please upgrade to the latest uv version, then update "
43+
"Python with: `uv python upgrade --reinstall`"
44+
)frome
45+
else:
46+
raiseImportError(
47+
"Failed to import tkagg backend. This is likely caused by using a "
48+
"Python executable based on python-build-standalone, which is not "
49+
"compatible with Tk. Recent versions of python-build-standalone "
50+
"should be compatible with Tk. Please update your python version "
51+
"or select another backend."
52+
)frome
53+
else:
54+
raise
2755

2856

2957
_log=logging.getLogger(__name__)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp