[pypy-issue] Issue #3036: Tkinter UnicodeEncodeError: 'mbcs' codec can't encode characters in position 0--1 (pypy/pypy)

Sasquatch issues-reply at bitbucket.org
Wed Jul 3 08:54:19 EDT 2019


New issue 3036: Tkinter UnicodeEncodeError: 'mbcs' codec can't encode characters in position 0--1
https://bitbucket.org/pypy/pypy/issues/3036/tkinter-unicodeencodeerror-mbcs-codec-cant

Sasquatch:

I am trying to get matplotlib working on my machine with pypy, but it seems tkinter is causing problems. I installed pypy from the nightly builds as recommend from here [https://stackoverflow.com/questions/56826170/value-error-invalid-argument-with-pypy-when-importing-pandas-and-plotly](https://stackoverflow.com/questions/56826170/value-error-invalid-argument-with-pypy-when-importing-pandas-and-plotly) When I import tkinter however, I get: 

‌

```python
>>>> import tkinter
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\pypy-c-jit-96765-24757bd09ed9-win32\lib-python\3\tkinter\__init__.py"
, line 36, in <module>
    import _tkinter # If this fails your Python may not be configured for Tk
  File "C:\pypy-c-jit-96765-24757bd09ed9-win32\lib_pypy\_tkinter\__init__.py", l
ine 55, in <module>
    tklib.Tcl_FindExecutable(os.fsencode(sys.executable))
  File "C:\pypy-c-jit-96765-24757bd09ed9-win32\lib-python\3\os.py", line 800, in
 fsencode
    return filename.encode(encoding, errors)
UnicodeEncodeError: 'mbcs' codec can't encode characters in position 0--1: mbcs
encoding does not support errors='surrogateescape'
```

And thus:

```
>>>> import matplotlib.pyplot
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\pypy-c-jit-96765-24757bd09ed9-win32\site-packages\matplotlib\pyplot.p
y", line 2355, in <module>
    switch_backend(rcParams["backend"])
  File "C:\pypy-c-jit-96765-24757bd09ed9-win32\site-packages\matplotlib\pyplot.p
y", line 221, in switch_backend
    backend_mod = importlib.import_module(backend_name)
  File "C:\pypy-c-jit-96765-24757bd09ed9-win32\lib-python\3\importlib\__init__.p
y", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 979, in _gcd_import
  File "<frozen importlib._bootstrap>", line 962, in _find_and_load
  File "<frozen importlib._bootstrap>", line 951, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
  File "<builtin>/frozen importlib._bootstrap_external", line 691, in exec_modul
e
  File "<frozen importlib._bootstrap>", line 206, in _call_with_frames_removed
  File "C:\pypy-c-jit-96765-24757bd09ed9-win32\site-packages\matplotlib\backends
\backend_tkagg.py", line 1, in <module>
    from . import _backend_tk
  File "C:\pypy-c-jit-96765-24757bd09ed9-win32\site-packages\matplotlib\backends
\_backend_tk.py", line 6, in <module>
    import tkinter as tk
  File "C:\pypy-c-jit-96765-24757bd09ed9-win32\lib-python\3\tkinter\__init__.py"
, line 36, in <module>
    import _tkinter # If this fails your Python may not be configured for Tk
  File "C:\pypy-c-jit-96765-24757bd09ed9-win32\lib_pypy\_tkinter\__init__.py", l
ine 55, in <module>
    tklib.Tcl_FindExecutable(os.fsencode(sys.executable))
  File "C:\pypy-c-jit-96765-24757bd09ed9-win32\lib-python\3\os.py", line 800, in
 fsencode
    return filename.encode(encoding, errors)
UnicodeEncodeError: 'mbcs' codec can't encode characters in position 0--1: mbcs
encoding does not support errors='surrogateescape'
```




More information about the pypy-issue mailing list