DEPRECATION WARNING: The system version of Tk is deprecated, M1 Mac in Vs Code – global Python
Question:
(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.
Here is the running code for reference.
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.
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:
Answers:
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:
Use:
echo "# For tkinter
export PATH="/usr/local/opt/tcl-tk/bin:$PATH"" >> ~/.zshrc
Or if you are using a bash
terminal:
echo "# For tkinter
export PATH="/usr/local/opt/tcl-tk/bin:$PATH"" >> ~/.bashrc
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
(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.
Here is the running code for reference.
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.
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:
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:
Use:
echo "# For tkinter
export PATH="/usr/local/opt/tcl-tk/bin:$PATH"" >> ~/.zshrc
Or if you are using a bash
terminal:
echo "# For tkinter
export PATH="/usr/local/opt/tcl-tk/bin:$PATH"" >> ~/.bashrc
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