poetry icon indicating copy to clipboard operation
poetry copied to clipboard

tkinter is missing init.tcl in poetry's virtualenv

Open alexchandel opened this issue 1 year ago • 1 comments

Description

tkinter requires some subfolders from the tcl folder of the CPython installation. However poetry does not copy these in, and poetry does not allow post-install scripts, meaning there is no simple way to automate this at installation.

Workarounds

Manually copy tcl8.6 and tk8.6 into the venv's Lib folder.

Poetry Installation Method

pipx

Operating System

Windows 11

Poetry Version

1.8.4

Poetry Configuration

poetry config --list
cache-dir = "C:\\Users\\me\\AppData\\Local\\pypoetry\\Cache"
experimental.system-git-client = false
installer.max-workers = null
installer.modern-installation = true
installer.no-binary = null
installer.parallel = true
keyring.enabled = true
solver.lazy-wheel = true
virtualenvs.create = true
virtualenvs.in-project = null
virtualenvs.options.always-copy = false
virtualenvs.options.no-pip = false
virtualenvs.options.no-setuptools = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = "{cache-dir}\\virtualenvs"  # C:\Users\me\AppData\Local\pypoetry\Cache\virtualenvs
virtualenvs.prefer-active-python = false
virtualenvs.prompt = "{project_name}-py{python_version}"
warnings.export = true


### Python Sysconfig

```bash session
python -m sysconfig
Platform: "win-amd64"
Python version: "3.13"
Current installation scheme: "nt"

Paths:
        data = "C:\Program Files\Python313"
        include = "C:\Program Files\Python313\Include"
        platinclude = "C:\Program Files\Python313\Include"
        platlib = "C:\Program Files\Python313\Lib\site-packages"
        platstdlib = "C:\Program Files\Python313\Lib"
        purelib = "C:\Program Files\Python313\Lib\site-packages"
        scripts = "C:\Program Files\Python313\Scripts"
        stdlib = "C:\Program Files\Python313\Lib"

Variables:
        BINDIR = "C:\Program Files\Python313"
        BINLIBDEST = "C:\Program Files\Python313\Lib"
        EXE = ".exe"
        EXT_SUFFIX = ".cp313-win_amd64.pyd"
        INCLUDEPY = "C:\Program Files\Python313\Include"
        LDLIBRARY = "python313.dll"
        LIBDEST = "C:\Program Files\Python313\Lib"
        LIBDIR = "C:\Program Files\Python313\libs"
        LIBRARY = "python313.dll"
        Py_GIL_DISABLED = "0"
        SOABI = "cp313-win_amd64"
        TZPATH = ""
        VERSION = "313"
        VPATH = "..\.."
        abi_thread = ""
        abiflags = ""
        base = "C:\Program Files\Python313"
        exec_prefix = "C:\Program Files\Python313"
        implementation = "Python"
        implementation_lower = "python"
        installed_base = "C:\Program Files\Python313"
        installed_platbase = "C:\Program Files\Python313"
        platbase = "C:\Program Files\Python313"
        platlibdir = "DLLs"
        prefix = "C:\Program Files\Python313"
        projectbase = "C:\Program Files\Python313"
        py_version = "3.13.0"
        py_version_nodot = "313"
        py_version_nodot_plat = "313"
        py_version_short = "3.13"
        srcdir = "C:\Program Files\Python313"
        userbase = "C:\Users\me\AppData\Roaming\Python"


### Example pyproject.toml

```TOML
Any vanilla script that uses `tkinter`:


poetry run vpcp.py
Traceback (most recent call last):
  File "C:\Projects\vpcp\vpcp.py", line 2758, in <module>
    main()
    ~~~~^^
  File "C:\Projects\vpcp\vpcp.py", line 2737, in main
    root = tk.Tk()
  File "C:\Program Files\Python313\Lib\tkinter\__init__.py", line 2459, 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:
    {C:/Program Files/Python313/lib/tcl8.6} C:/Users/me/AppData/Local/pypoetry/Cache/virtualenvs/vpcp-hmXVBWTb-py3.13/lib/tcl8.6 C:/Users/me/AppData/Local/pypoetry/Cache/virtualenvs/lib/tcl8.6 C:/Users/me/AppData/Local/pypoetry/Cache/virtualenvs/vpcp-hmXVBWTb-py3.13/library C:/Users/me/AppData/Local/pypoetry/Cache/virtualenvs/library C:/Users/me/AppData/Local/pypoetry/Cache/virtualenvs/tcl8.6.14/library C:/Users/me/AppData/Local/pypoetry/Cache/tcl8.6.14/library



This probably means that Tcl wasn't installed properly.


### Poetry Runtime Logs

```bash session
N/A

alexchandel avatar Dec 06 '24 19:12 alexchandel

Poetry uses virtualenv, you will want to take this to that project

dimbleby avatar Dec 06 '24 20:12 dimbleby

This is not a Poetry issue.

abn avatar Jan 14 '25 21:01 abn

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

github-actions[bot] avatar Feb 14 '25 00:02 github-actions[bot]