{"id":359,"date":"2021-08-29T13:20:54","date_gmt":"2021-08-29T04:20:54","guid":{"rendered":"https:\/\/blog.peddals.com\/?p=359"},"modified":"2024-01-03T23:38:10","modified_gmt":"2024-01-03T14:38:10","slug":"install_tkinter_by_brew","status":"publish","type":"post","link":"https:\/\/blog.peddals.com\/en\/install_tkinter_by_brew\/","title":{"rendered":"You may need to install tkinter separately if it&#8217;s gone."},"content":{"rendered":"\n<p>Recently I started working on some small Python GUI programs. Last year on an Intel Mac I found tkinter was not good as it had some issues with Japanese input method so I gave up. It&#8217;s been more than a year and I have a M1 (arm) Mac so there might be some improvements with tkinter. Upgrading Python3 (and all programs) by brew was the first step I tried, then tkinter module was unable to be loaded any longer&#8230;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">You always better read install log which gives you necessary info.<\/h2>\n\n\n\n<p>I didn&#8217;t really pay attention to the brew log when upgraded Python from 3.9.1 to 3.9.6 as it was successful and must be a minor update&#8230; Soon after the upgrade my Python scripts that import tkinter in a pipenv shell started giving me error &#8220;<code>No module named '_tkinter'<\/code>&#8220;. Lots of trials and errors referring to several web pages, tech threads, etc. didn&#8217;t help. Tried setting up pipenv from scratch, installed tcl-tk by brew, added PATH and some other tcl-tk variables to .zshrc to no avail. I finally decided to give up and went to bed &#8211; worst case scenario I need to uninstall and install all Python related things including brew&#8230; On the day-2, I was calmer than last night and started identifying the scope of the problem &#8211; ok, tkinter cannot be found even out of my pipenv. It&#8217;s really gone from macOS Big Sur at some point. Reviewed steps taken on the day-1 and it didn&#8217;t take much time to find the below:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism off-numbers lang-zsh\" data-lang=\"ZSH\"><code>% brew info python3\npython@3.9: stable 3.9.6 (bottled)\nInterpreted, interactive, object-oriented programming language\nhttps:\/\/www.python.org\/\n...snip...\ntkinter is no longer included with this formula, but it is available separately:\n  brew install python-tk@3.9\n...snip...<\/code><\/pre><\/div>\n\n\n\n<p>Aha! If I read the brew install log once completed, I didn&#8217;t need to waste 6 hours and would have a sweet dream. Anyways, if your tkinter is gone after upgrading Python by brew, just execute another command <code><strong>brew install python-tk@3.9<\/strong><\/code> and install it as well. My scripts finally open tkinter GUI windows with no error.<\/p>\n\n\n\n<p>Most of Python documents or webpages suggest you to try tkinter for GUI development as it&#8217;s installed by default, but it&#8217;s not true anymore especially for those of you who install Python by brew on Mac.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Example of the error in my case<\/h2>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism off-numbers lang-zsh\" data-lang=\"ZSH\"><code>% python3 -m tkinter\nTraceback (most recent call last):\nFile &quot;\/opt\/homebrew\/Cellar\/python@3.9\/3.9.6\/Frameworks\/Python.framework\/Versions\/3.9\/lib\/python3.9\/runpy.py&quot;, line 188, in _run_module_as_main\nmod_name, mod_spec, code = _get_module_details(mod_name, _Error)\nFile &quot;\/opt\/homebrew\/Cellar\/python@3.9\/3.9.6\/Frameworks\/Python.framework\/Versions\/3.9\/lib\/python3.9\/runpy.py&quot;, line 147, in _get_module_details\nreturn _get_module_details(pkg_main_name, error)\nFile &quot;\/opt\/homebrew\/Cellar\/python@3.9\/3.9.6\/Frameworks\/Python.framework\/Versions\/3.9\/lib\/python3.9\/runpy.py&quot;, line 111, in _get_module_details\n__import__(pkg_name)\nFile &quot;\/opt\/homebrew\/Cellar\/python@3.9\/3.9.6\/Frameworks\/Python.framework\/Versions\/3.9\/lib\/python3.9\/tkinter\/__init__.py&quot;, line 37, in\nimport _tkinter # If this fails your Python may not be configured for Tk\nModuleNotFoundError: No module named &#39;_tkinter&#39;<\/code><\/pre><\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently I started working on some small Python GUI programs. Last year on an Intel Mac I found tkinter was no &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.peddals.com\/en\/install_tkinter_by_brew\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;You may need to install tkinter separately if it&#8217;s gone.&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":357,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_locale":"en_US","_original_post":"https:\/\/blog.peddals.com\/?p=355","footnotes":""},"categories":[8,4,23],"tags":[13,12,18],"class_list":["post-359","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-macos","category-python","category-troubleshooting","tag-m1","tag-mac","tag-python","en-US"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>You may need to install tkinter separately if it&#039;s gone. | Peddals Blog<\/title>\n<meta name=\"description\" content=\"How to install tkinter by brew for Python 3.9. macOS Big Sur\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/blog.peddals.com\/en\/install_tkinter_by_brew\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"You may need to install tkinter separately if it&#039;s gone. | Peddals Blog\" \/>\n<meta property=\"og:description\" content=\"How to install tkinter by brew for Python 3.9. macOS Big Sur\" \/>\n<meta property=\"og:url\" content=\"https:\/\/blog.peddals.com\/en\/install_tkinter_by_brew\/\" \/>\n<meta property=\"og:site_name\" content=\"Peddals Blog\" \/>\n<meta property=\"article:published_time\" content=\"2021-08-29T04:20:54+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-01-03T14:38:10+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/blog.peddals.com\/wp-content\/uploads\/2021\/08\/fdbe36eecaa86007f61bbfdb2a9db753.png\" \/>\n\t<meta property=\"og:image:width\" content=\"559\" \/>\n\t<meta property=\"og:image:height\" content=\"45\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Handsome\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Handsome\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/blog.peddals.com\\\/en\\\/install_tkinter_by_brew\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/blog.peddals.com\\\/en\\\/install_tkinter_by_brew\\\/\"},\"author\":{\"name\":\"Handsome\",\"@id\":\"https:\\\/\\\/blog.peddals.com\\\/#\\\/schema\\\/person\\\/81b2dabca748c3d11a45722f02d9d994\"},\"headline\":\"You may need to install tkinter separately if it&#8217;s gone.\",\"datePublished\":\"2021-08-29T04:20:54+00:00\",\"dateModified\":\"2024-01-03T14:38:10+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/blog.peddals.com\\\/en\\\/install_tkinter_by_brew\\\/\"},\"wordCount\":363,\"commentCount\":4,\"publisher\":{\"@id\":\"https:\\\/\\\/blog.peddals.com\\\/#\\\/schema\\\/person\\\/81b2dabca748c3d11a45722f02d9d994\"},\"image\":{\"@id\":\"https:\\\/\\\/blog.peddals.com\\\/en\\\/install_tkinter_by_brew\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/blog.peddals.com\\\/wp-content\\\/uploads\\\/2021\\\/08\\\/fdbe36eecaa86007f61bbfdb2a9db753.png\",\"keywords\":[\"m1\",\"mac\",\"Python\"],\"articleSection\":[\"macOS\",\"Python\",\"Troubleshooting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/blog.peddals.com\\\/en\\\/install_tkinter_by_brew\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/blog.peddals.com\\\/en\\\/install_tkinter_by_brew\\\/\",\"url\":\"https:\\\/\\\/blog.peddals.com\\\/en\\\/install_tkinter_by_brew\\\/\",\"name\":\"You may need to install tkinter separately if it's gone. | Peddals Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/blog.peddals.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/blog.peddals.com\\\/en\\\/install_tkinter_by_brew\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/blog.peddals.com\\\/en\\\/install_tkinter_by_brew\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/blog.peddals.com\\\/wp-content\\\/uploads\\\/2021\\\/08\\\/fdbe36eecaa86007f61bbfdb2a9db753.png\",\"datePublished\":\"2021-08-29T04:20:54+00:00\",\"dateModified\":\"2024-01-03T14:38:10+00:00\",\"description\":\"How to install tkinter by brew for Python 3.9. macOS Big Sur\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/blog.peddals.com\\\/en\\\/install_tkinter_by_brew\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/blog.peddals.com\\\/en\\\/install_tkinter_by_brew\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/blog.peddals.com\\\/en\\\/install_tkinter_by_brew\\\/#primaryimage\",\"url\":\"https:\\\/\\\/blog.peddals.com\\\/wp-content\\\/uploads\\\/2021\\\/08\\\/fdbe36eecaa86007f61bbfdb2a9db753.png\",\"contentUrl\":\"https:\\\/\\\/blog.peddals.com\\\/wp-content\\\/uploads\\\/2021\\\/08\\\/fdbe36eecaa86007f61bbfdb2a9db753.png\",\"width\":559,\"height\":45},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/blog.peddals.com\\\/en\\\/install_tkinter_by_brew\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u30db\u30fc\u30e0\",\"item\":\"https:\\\/\\\/blog.peddals.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"You may need to install tkinter separately if it&#8217;s gone.\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/blog.peddals.com\\\/#website\",\"url\":\"https:\\\/\\\/blog.peddals.com\\\/\",\"name\":\"Peddals Blog\",\"description\":\"AI, LLM, Python, Mac, Pythonista3, iOS, etc. in Japanese and English\",\"publisher\":{\"@id\":\"https:\\\/\\\/blog.peddals.com\\\/#\\\/schema\\\/person\\\/81b2dabca748c3d11a45722f02d9d994\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/blog.peddals.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/blog.peddals.com\\\/#\\\/schema\\\/person\\\/81b2dabca748c3d11a45722f02d9d994\",\"name\":\"Handsome\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/51d7363349ec538c4d62c9ebe89488fd7388729ad0c9dfeebd8bb32ebfb11f17?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/51d7363349ec538c4d62c9ebe89488fd7388729ad0c9dfeebd8bb32ebfb11f17?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/51d7363349ec538c4d62c9ebe89488fd7388729ad0c9dfeebd8bb32ebfb11f17?s=96&d=mm&r=g\",\"caption\":\"Handsome\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/51d7363349ec538c4d62c9ebe89488fd7388729ad0c9dfeebd8bb32ebfb11f17?s=96&d=mm&r=g\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"You may need to install tkinter separately if it's gone. | Peddals Blog","description":"How to install tkinter by brew for Python 3.9. macOS Big Sur","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/blog.peddals.com\/en\/install_tkinter_by_brew\/","og_locale":"en_US","og_type":"article","og_title":"You may need to install tkinter separately if it's gone. | Peddals Blog","og_description":"How to install tkinter by brew for Python 3.9. macOS Big Sur","og_url":"https:\/\/blog.peddals.com\/en\/install_tkinter_by_brew\/","og_site_name":"Peddals Blog","article_published_time":"2021-08-29T04:20:54+00:00","article_modified_time":"2024-01-03T14:38:10+00:00","og_image":[{"width":559,"height":45,"url":"https:\/\/blog.peddals.com\/wp-content\/uploads\/2021\/08\/fdbe36eecaa86007f61bbfdb2a9db753.png","type":"image\/png"}],"author":"Handsome","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Handsome","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/blog.peddals.com\/en\/install_tkinter_by_brew\/#article","isPartOf":{"@id":"https:\/\/blog.peddals.com\/en\/install_tkinter_by_brew\/"},"author":{"name":"Handsome","@id":"https:\/\/blog.peddals.com\/#\/schema\/person\/81b2dabca748c3d11a45722f02d9d994"},"headline":"You may need to install tkinter separately if it&#8217;s gone.","datePublished":"2021-08-29T04:20:54+00:00","dateModified":"2024-01-03T14:38:10+00:00","mainEntityOfPage":{"@id":"https:\/\/blog.peddals.com\/en\/install_tkinter_by_brew\/"},"wordCount":363,"commentCount":4,"publisher":{"@id":"https:\/\/blog.peddals.com\/#\/schema\/person\/81b2dabca748c3d11a45722f02d9d994"},"image":{"@id":"https:\/\/blog.peddals.com\/en\/install_tkinter_by_brew\/#primaryimage"},"thumbnailUrl":"https:\/\/blog.peddals.com\/wp-content\/uploads\/2021\/08\/fdbe36eecaa86007f61bbfdb2a9db753.png","keywords":["m1","mac","Python"],"articleSection":["macOS","Python","Troubleshooting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/blog.peddals.com\/en\/install_tkinter_by_brew\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/blog.peddals.com\/en\/install_tkinter_by_brew\/","url":"https:\/\/blog.peddals.com\/en\/install_tkinter_by_brew\/","name":"You may need to install tkinter separately if it's gone. | Peddals Blog","isPartOf":{"@id":"https:\/\/blog.peddals.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/blog.peddals.com\/en\/install_tkinter_by_brew\/#primaryimage"},"image":{"@id":"https:\/\/blog.peddals.com\/en\/install_tkinter_by_brew\/#primaryimage"},"thumbnailUrl":"https:\/\/blog.peddals.com\/wp-content\/uploads\/2021\/08\/fdbe36eecaa86007f61bbfdb2a9db753.png","datePublished":"2021-08-29T04:20:54+00:00","dateModified":"2024-01-03T14:38:10+00:00","description":"How to install tkinter by brew for Python 3.9. macOS Big Sur","breadcrumb":{"@id":"https:\/\/blog.peddals.com\/en\/install_tkinter_by_brew\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/blog.peddals.com\/en\/install_tkinter_by_brew\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/blog.peddals.com\/en\/install_tkinter_by_brew\/#primaryimage","url":"https:\/\/blog.peddals.com\/wp-content\/uploads\/2021\/08\/fdbe36eecaa86007f61bbfdb2a9db753.png","contentUrl":"https:\/\/blog.peddals.com\/wp-content\/uploads\/2021\/08\/fdbe36eecaa86007f61bbfdb2a9db753.png","width":559,"height":45},{"@type":"BreadcrumbList","@id":"https:\/\/blog.peddals.com\/en\/install_tkinter_by_brew\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u30db\u30fc\u30e0","item":"https:\/\/blog.peddals.com\/"},{"@type":"ListItem","position":2,"name":"You may need to install tkinter separately if it&#8217;s gone."}]},{"@type":"WebSite","@id":"https:\/\/blog.peddals.com\/#website","url":"https:\/\/blog.peddals.com\/","name":"Peddals Blog","description":"AI, LLM, Python, Mac, Pythonista3, iOS, etc. in Japanese and English","publisher":{"@id":"https:\/\/blog.peddals.com\/#\/schema\/person\/81b2dabca748c3d11a45722f02d9d994"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/blog.peddals.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/blog.peddals.com\/#\/schema\/person\/81b2dabca748c3d11a45722f02d9d994","name":"Handsome","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/51d7363349ec538c4d62c9ebe89488fd7388729ad0c9dfeebd8bb32ebfb11f17?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/51d7363349ec538c4d62c9ebe89488fd7388729ad0c9dfeebd8bb32ebfb11f17?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/51d7363349ec538c4d62c9ebe89488fd7388729ad0c9dfeebd8bb32ebfb11f17?s=96&d=mm&r=g","caption":"Handsome"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/51d7363349ec538c4d62c9ebe89488fd7388729ad0c9dfeebd8bb32ebfb11f17?s=96&d=mm&r=g"}}]}},"_links":{"self":[{"href":"https:\/\/blog.peddals.com\/wp-json\/wp\/v2\/posts\/359","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.peddals.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.peddals.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.peddals.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.peddals.com\/wp-json\/wp\/v2\/comments?post=359"}],"version-history":[{"count":2,"href":"https:\/\/blog.peddals.com\/wp-json\/wp\/v2\/posts\/359\/revisions"}],"predecessor-version":[{"id":694,"href":"https:\/\/blog.peddals.com\/wp-json\/wp\/v2\/posts\/359\/revisions\/694"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.peddals.com\/wp-json\/wp\/v2\/media\/357"}],"wp:attachment":[{"href":"https:\/\/blog.peddals.com\/wp-json\/wp\/v2\/media?parent=359"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.peddals.com\/wp-json\/wp\/v2\/categories?post=359"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.peddals.com\/wp-json\/wp\/v2\/tags?post=359"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}