Skip to content

Can't use tkinter with new venv set up with uv #7036

@dstansby

Description

@dstansby

(Maintainer edit)

NOTE If you are still affected by this, try reinstalling the managed Python interpreter

python install --reinstall ...

uv venv
source .venv/bin/activate
python -c "from tkinter import Tk; window = Tk()" 

This gives me the error message:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/dstansby/.local/share/uv/python/cpython-3.12.5-macos-aarch64-none/lib/python3.12/tkinter/__init__.py", line 2346, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_tkinter.TclError: Can't find a usable init.tcl in the following directories: 
    /tools/deps/lib/tcl8.6 /Users/dstansby/.venv/lib/tcl8.6 /Users/dstansby/lib/tcl8.6 /Users/dstansby/.venv/library /Users/dstansby/library /Users/dstansby/tcl8.6.12/library /Users/tcl8.6.12/library



This probably means that Tcl wasn't installed properly.

I can successfully run python -c "from tkinter import Tk; window = Tk()" in a fresh conda environment, but when I install python on conda it also installs tk, so maybe that's why it works? Maybe this isn't an issue with uv?, but if anyone knows how to get this working I'd be very gateful!

uv 0.4.4 (Homebrew 2024-09-04)
macOS

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcompatibilityCompatibility with a specification or another tool

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions