jdx / mise

dev tools, env vars, task runner
https://mise.jdx.dev
MIT License
8.28k stars 219 forks source link

tkinter not available #2189

Open bwagner opened 1 month ago

bwagner commented 1 month ago

Describe the bug tkinter not available

To Reproduce

mise install python@3.12.3
mise global python@3.12.3
python -V
Python 3.12.3
python
>>> import tkinter
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "~/.local/share/mise/installs/python/3.12.3/lib/python3.12/tkinter/__init__.py", line 38, in <module>
    import _tkinter # If this fails your Python may not be configured for Tk
    ^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named '_tkinter'

Expected behavior import tkinter should not cause ModuleNotFoundError

mise doctor output

version: 2024.5.21 macos-arm64 (2024-05-23)
activated: yes
shims_on_path: no

build_info:
  Target: aarch64-apple-darwin
  Features: DEFAULT, NATIVE_TLS
  Built: Thu, 23 May 2024 03:16:32 +0000
  Rust Version: rustc 1.78.0 (9b00956e5 2024-04-29) (Homebrew)
  Profile: release

shell:
  /opt/homebrew/bin/bash
  GNU bash, version 5.2.26(1)-release (aarch64-apple-darwin23.2.0)
  Copyright (C) 2022 Free Software Foundation, Inc.
  License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

  This is free software; you are free to change and redistribute it.
  There is NO WARRANTY, to the extent permitted by law.

dirs:
  data: ~/.local/share/mise
  config: ~/.config/mise
  cache: ~/Library/Caches/mise
  state: ~/.local/state/mise
  shims: ~/.local/share/mise/shims

config_files:
  ~/.tool-versions
  ~/.config/mise/config.toml

backends:
  cargo
  core
  go
  npm
  pipx
  ubi

plugins:
  bun     (core)
  deno    (core)
  erlang  (core)
  go      (core)
  java    (core)
  node    (core)
  python  (core)
  ruby    (core)

toolset:
  python@3.12.3

env_vars:
  MISE_SHELL=bash

settings:
  activate_aggressive = false
  all_compile = false
  always_keep_download = false
  always_keep_install = false
  asdf_compat = false
  cargo_binstall = true
  color = true
  disable_default_shorthands = false
  disable_tools = []
  experimental = false
  go_default_packages_file = "~/.default-go-packages"
  go_download_mirror = "https://dl.google.com/go"
  go_repo = "https://github.com/golang/go"
  go_set_gopath = false
  go_set_goroot = true
  go_skip_checksum = false
  jobs = 4
  legacy_version_file = true
  legacy_version_file_disable_tools = []
  node_compile = false
  not_found_auto_install = true
  paranoid = false
  plugin_autoupdate_last_check_duration = "7d"
  python_default_packages_file = "~/.default-python-packages"
  python_pyenv_repo = "https://github.com/pyenv/pyenv.git"
  raw = false
  trusted_config_paths = []
  quiet = false
  verbose = false
  yes = false
  ci = false
  debug = false
  trace = false
  log_level = "info"
  python_venv_auto_create = false

  [status]
  missing_tools = "if_other_versions_installed"
  show_env = false
  show_tools = false

No warnings found
No problems found

Additional context Add any other context about the problem here.

bwagner commented 1 week ago

Ok, here's a fix:

brew install tcl-tk
export TCL_LIBRARY=$(brew --prefix tcl-tk)/lib; export TK_LIBRARY=$(brew --prefix tcl-tk)/lib
mise uninstall python@3.12.3
mise install python@3.12.3
# open a new shell to get rid of environment variables and run:
python -m tkinter
# which should open the Tcl/Tk test window

image