I did also have this issue, but as @furas did mention tkinter is not installed by default on some ubuntu serverion(i run (in windows)ubuntu 22.04 LTS) with Poetry (version 1.6.1) and python 3.10
So I did have to install tkinter with apt-get by: sudo apt-get install python3-tk
Now tkinter is installed but it still cant be added to the .tomel, but if i dont have it added and run the project with "poetry run python project.py" it do run without any problem. It seams to be the same with all standard Python libraries. My .toml is then:
[tool.poetry]
name = "test-gui"
version = "0.1.0"
description = ""
authors = ["JonTheBaboon"]
readme = "README.md"
[tool.poetry.dependencies]
python = "^3.10"
pillow = "^10.1.0"
tk = "^0.1.0"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
You mentions tk, if you run "poetry add tk", you will get another package "TensorKit", see the poetry.lock file:
name = "tk"
version = "0.1.0"
description = "TensorKit is a deep learning helper between Python and C++."
optional = false
python-versions = "*"
Tkinter
with upperT
. Do you run it on some Linux server? In most systemstkinter
is installed withPython
but on some Ubuntu Servers it needed to install manually librarypython-tkinter
using toolapt
(because Ubuntu Server doesn't have graphic mode so it can't display GUIs - so Python doesn't needtkinter
module and it is not installed with Ubuntu Server) – Quadruplepython -m tkinter
works fine (opens a mini Tk test window) butpoetry run python -m tkinter
fails withModuleNotFoundError: No module named '_tkinter'
(and some preceding error text too). Sincetkinter
is part of the std lib, you can't install it — it's not on PyPi, or anywhere — just like how you can't installos
,json
, etc. Not sure what the solution is here except to ask the poetry devs to fix the issue or install the necessary libraries separately as in https://mcmap.net/q/1391363/-python-tkinter-modulenotfounderror-no-module-named-39-_tkinter-39/5496433 and related questions. – Session