Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tkinter.Tcl().eval fails if the bundle path contains non-ASCII characters #121

Open
MaxBQb opened this issue Jan 11, 2022 · 3 comments
Open
Labels
enhancement New feature or request

Comments

@MaxBQb
Copy link

MaxBQb commented Jan 11, 2022

Python: 3.10
System: Windows 10

pip freeze:

cachetools==5.0.0
future==0.18.2
pefile==2021.9.3
py2exe==0.11.0.1
PySimpleGUI==4.56.0

main.py:

import PySimpleGUI

setup.py:

from distutils.core import setup
import py2exe


setup(
    console=['main.py'],
    name="example",
    version="0.0.2",
    options=dict(py2exe=dict(
        dist_dir='тест'
    ))
)

build logs:

D:\scripts\issueReproduction\venv\Scripts\python.exe D:/scripts/issueReproduction/setup.py py2exe
D:\scripts\issueReproduction\setup.py:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
  from distutils.core import setup
running py2exe

  13 missing Modules                 
  ------------------                 
? __main__                            imported from bdb, pdb
? _frozen_importlib                   imported from importlib, importlib.abc, zipimport
? _frozen_importlib_external          imported from importlib, importlib._bootstrap, importlib.abc, zipimport
? _posixshmem                         imported from multiprocessing.resource_tracker, multiprocessing.shared_memory
? _winreg                             imported from platform
? asyncio.DefaultEventLoopPolicy      imported from -
? dummy.Process                       imported from multiprocessing.pool
? java.lang                           imported from platform
? org.python.core                     imported from copy, pickle
? os.path                             imported from ctypes._aix, distutils.file_util, os, pkgutil, py_compile, sysconfig, tracemalloc, unittest, unittest.util
? pep517                              imported from importlib.metadata
? readline                            imported from cmd, code, pdb
? resource                            imported from test.support
Building 'тест\main.exe'.
Building shared code archive 'тест\library.zip'.
Copy c:\program files\python310\python310.dll to тест
Copy C:\Program Files\Python310\DLLs\select.pyd to тест\select.pyd
Copy C:\Program Files\Python310\DLLs\_bz2.pyd to тест\_bz2.pyd
Copy C:\Program Files\Python310\DLLs\_lzma.pyd to тест\_lzma.pyd
Copy C:\Program Files\Python310\DLLs\unicodedata.pyd to тест\unicodedata.pyd
Copy C:\Program Files\Python310\DLLs\_hashlib.pyd to тест\_hashlib.pyd
Copy C:\Program Files\Python310\DLLs\_decimal.pyd to тест\_decimal.pyd
Copy C:\Program Files\Python310\DLLs\_socket.pyd to тест\_socket.pyd
Copy C:\Program Files\Python310\DLLs\pyexpat.pyd to тест\pyexpat.pyd
Copy C:\Program Files\Python310\DLLs\_ssl.pyd to тест\_ssl.pyd
Copy C:\Program Files\Python310\DLLs\_queue.pyd to тест\_queue.pyd
Copy C:\Program Files\Python310\DLLs\_elementtree.pyd to тест\_elementtree.pyd
Copy C:\Program Files\Python310\DLLs\_testcapi.pyd to тест\_testcapi.pyd
Copy C:\Program Files\Python310\DLLs\_ctypes.pyd to тест\_ctypes.pyd
Copy C:\Program Files\Python310\DLLs\_tkinter.pyd to тест\_tkinter.pyd
Copy C:\Program Files\Python310\DLLs\_testinternalcapi.pyd to тест\_testinternalcapi.pyd
Copy C:\Program Files\Python310\DLLs\_asyncio.pyd to тест\_asyncio.pyd
Copy C:\Program Files\Python310\DLLs\_multiprocessing.pyd to тест\_multiprocessing.pyd
Copy C:\Program Files\Python310\DLLs\_overlapped.pyd to тест\_overlapped.pyd
Copy C:\Program Files\Python310\DLLs\_uuid.pyd to тест\_uuid.pyd
Copy DLL C:\Program Files\Python310\DLLs\tk86t.dll to тест\
Copy DLL C:\Program Files\Python310\DLLs\tcl86t.dll to тест\
Copy DLL C:\Program Files\Python310\DLLs\libcrypto-1_1.dll to тест\
Copy DLL C:\Program Files\Python310\DLLs\libffi-7.dll to тест\
Copy DLL C:\Program Files\Python310\DLLs\libssl-1_1.dll to тест\

Process finished with exit code 0

And when I'm tries to start main.exe:

PS D:\scripts\issueReproduction\тест> .\main.exe
Traceback (most recent call last):
  File "main.py", line 1, in <module>
  File "PySimpleGUI\__init__.pyc", line 2, in <module>
  File "PySimpleGUI\PySimpleGUI.pyc", line 137, in <module>
  File "tkinter\__init__.pyc", line 2401, in Tcl
  File "tkinter\__init__.pyc", line 2299, in __init__
_tkinter.TclError: Can't find a usable init.tcl in the following directories:
    {D:\scripts\issueReproduction\òåñò\lib\tcl} D:/scripts/issueReproduction/òåñò/lib/tcl8.6 D:/scripts/issueReproduction/lib/tcl8.6 D:/scripts/issueReproduction/lib/tcl8.6 D:/scripts/lib/tcl8.6 D:/scripts/issueReproduction/library D:/scripts/library D:/scripts/tcl8.6.10/library D:/tcl8.6.10/library



This probably means that Tcl wasn't installed properly.

It appears when path/to/program contains non ASCII symbols (in this example word test in Russian)
For ASCII only:

PS D:\scripts\onlyASCII\dist> .\main.exe
PS D:\scripts\onlyASCII\dist>

When I'm start main.py script in such directory (rename source code directory to тест), it work's fine

@MaxBQb
Copy link
Author

MaxBQb commented Jan 11, 2022

Note:

main.py:

import tkinter

No errors at runtime :)

@albertosottile
Copy link
Member

Just importing tkinter might not be enough to trigger the bug. Could you please try again with the import sequence that PySimpleGUI uses?

import tkinter as tk
from tkinter import filedialog
from tkinter.colorchooser import askcolor
from tkinter import ttk
import tkinter.scrolledtext as tkst
import tkinter.font

tclversion_detailed = tkinter.Tcl().eval('info patchlevel')
print(tclversion_detailed)

It looks like this might also be a bug, however I would encourage you to just use ASCII characters in your paths as there might also be many other problems after this later down the road....

@MaxBQb
Copy link
Author

MaxBQb commented Jan 18, 2022

First of all, I can't insist on using ASCII-only directory names, when I work with users who don't even know English (and they are not happy with the idea of using transliteration, "Why do other programs can? What is wrong with your app?", etc.), so unfortunately this is not an option.

Well, as I mentioned before this only appears with PySimpleGUI import, not with raw tkinter import
So I find out that this is enough to trigger bug:

main.py:

from tkinter import Tcl
Tcl().eval('info patchlevel')

@albertosottile albertosottile changed the title Tcl wasn't installed properly PySimpleGUI fails if the bundle path contains non-ASCII characters Feb 12, 2022
@MaxBQb MaxBQb changed the title PySimpleGUI fails if the bundle path contains non-ASCII characters tkinter.Tcl().eval fails if the bundle path contains non-ASCII characters Feb 15, 2022
@albertosottile albertosottile added the enhancement New feature or request label May 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants