弃用警告:TK的系统版本已弃用,M1 Mac在VS代码中 - 全局Python

发布于 2025-02-03 16:39:41 字数 1303 浏览 2 评论 0原文

(M1 MBA 2020,MACOS 12.3.1) 因此,在VS代码中,当我从我的usr/local/local/bin tkinter中选择解释器为Python 3.8.9时,它会按照我的要求运行。

这是用于参考的运行代码。

当我尝试使用全局python 3.8.9 interneter(usr/bin/python3)时,出现了问题。当代码运行时,应用程序最终看起来像这样。

另外,当我运行代码时,终端读取以下内容:

DEPRECATION WARNING: The system version of Tk is deprecated and may be removed in a future release. Please don't rely on it. Set TK_SILENCE_DEPRECATION=1 to suppress this warning.

我如何解决此错误?或更新我的全局TKINTER版本而不会偏离Python 3.8.9。此外,如果需要更多信息,我会很乐意提供,对不起,我是

该应用中使用的这些包装的新手: tkinter,枕头,tkmacosx

最后一件事,当我摆脱所有包装tkmacosx的提及时,该应用看起来像这样:

“无tkmacosx”

(M1 MBA 2020, MacOS 12.3.1)
So inside of Vs Code, when I select my interpreter as Python 3.8.9 from my usr/local/bin Tkinter it runs as I want it to.

This is the working interpreter

Here is the running code for reference.

Running Code

The problem arises when I am trying to use the Global Python 3.8.9 interpreter (usr/bin/python3). When the code runs, the application ends up looking like this.

not working tkinter

Additionally, when I run the code the terminal reads the following:

DEPRECATION WARNING: The system version of Tk is deprecated and may be removed in a future release. Please don't rely on it. Set TK_SILENCE_DEPRECATION=1 to suppress this warning.

How is it possible for me to fix this error? Or update my global Tkinter version without straying away from Python 3.8.9. Furthermore if any more info is needed I'll be happy to provide, sorry I'm new to this stuff ????

Packages used in the app:
tkinter, Pillow, tkmacosx

One last thing, when I get rid of all mentions of the package Tkmacosx, the app appears like this:

app without tkmacosx

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

廻憶裏菂餘溫 2025-02-10 16:39:42

如果您安装了自制的tk,则可以使用以下方式更新tk

brew uninstall tcl-tk --devel
brew install tcl-tk

/tcl-tk/bin:$ path“ to .zshrc file:

如果您使用zsh终端:

of

echo "# For tkinter 
export PATH=\"/usr/local/opt/tcl-tk/bin:\$PATH\"" >> ~/.zshrc
source ~/.zshrc

或者,如果您使用的是bash终端:

echo "# For tkinter 
export PATH=\"/usr/local/opt/tcl-tk/bin:\$PATH\"" >> ~/.bashrc
source ~/.bashrc

如果以上步骤不起作用,则您 May 需要安装另一个软件包(@goker):

brew install [email protected]

homebrew

参考

代码>升级文档

If you have Homebrew installed, you can update tk with:

brew uninstall tcl-tk --devel
brew install tcl-tk

Which is the recommended option

Then you may need to add export PATH="/usr/local/opt/tcl-tk/bin:$PATH" to your .zshrc file:

If you are using a zsh terminal:

Zsh tab

Use:

echo "# For tkinter 
export PATH=\"/usr/local/opt/tcl-tk/bin:\$PATH\"" >> ~/.zshrc
source ~/.zshrc

Or if you are using a bash terminal:

echo "# For tkinter 
export PATH=\"/usr/local/opt/tcl-tk/bin:\$PATH\"" >> ~/.bashrc
source ~/.bashrc

If the steps above didn't work, you may need to install another package (@goker):

brew install [email protected]

Homebrew

Reference

Python's offical tk upgrade docs

寻梦旅人 2025-02-10 16:39:42

https://stackoverflow.com/a/72472483/9842697 的答案。

(此注释是对答案的回应)

我已经通过Pyenv安装了Python 3.10.6,Pyenv通过Homebrew安装了Pyenv。
(使用-Devel不起作用的卸载)

  • 与Pyenv一起安装TCL-TK并用Pyenv重新安装Python 3.10.6,使Python安装使用TCL-TK的自制版本,此后闲置效果很好。
% brew install tcl-tk
% pyenv install 3.10.6
% python
>>> import idlelib.idle

Answer from Freddy below https://stackoverflow.com/a/72472483/9842697 worked.

(this note was to be a response to the answer)

I have python 3.10.6 installed via pyenv, pyenv installed via homebrew.
(Uninstall with --devel does not work)

  • installing tcl-tk with homebrew and reinstalling python 3.10.6 with pyenv, makes the python installation use the homebrew version of tcl-tk and after this IDLE works fine.
% brew install tcl-tk
% pyenv install 3.10.6
% python
>>> import idlelib.idle
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文