Skip to content

Compilation Error with Python 3.6.1/3.6.3 with Tkinter #75998

Closed

Description

@jpc2350
mannequin
BPO 31817
Nosy @ned-deily, @jpc2350, @iritkatriel

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2022-01-30.16:51:17.463>
created_at = <Date 2017-10-19.10:07:54.917>
labels = ['build', 'expert-tkinter']
title = 'Compilation Error with Python 3.6.1/3.6.3 with Tkinter'
updated_at = <Date 2022-01-30.16:51:17.463>
user = 'https://github.com/jpc2350'

bugs.python.org fields:

activity = <Date 2022-01-30.16:51:17.463>
actor = 'iritkatriel'
assignee = 'none'
closed = True
closed_date = <Date 2022-01-30.16:51:17.463>
closer = 'iritkatriel'
components = ['Tkinter']
creation = <Date 2017-10-19.10:07:54.917>
creator = 'jpc2350'
dependencies = []
files = []
hgrepos = []
issue_num = 31817
keywords = []
message_count = 14.0
messages = ['304612', '304675', '304676', '304788', '305431', '305472', '306272', '307118', '314638', '316385', '319861', '370284', '370289', '411150']
nosy_count = 5.0
nosy_names = ['ned.deily', 'jpc2350', 'dplusplus', 'iritkatriel', 'zhang']
pr_nums = []
priority = 'normal'
resolution = 'out of date'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'compile error'
url = 'https://bugs.python.org/issue31817'
versions = ['Python 3.6']

Activity

  1. jpc2350 commented on Oct 19, 2017

    jpc2350mannequin
    MannequinAuthor

    Hi Guys,

    I'm trying to build Python 3.6.1 and 3.6.3, with both, .configure / make / make install work correctly as they should, however, trying to import _tkinter doesn't work.

    Going back to the compilation, I get the following error in the make log:

    *** WARNING: renaming "_tkinter" since importing it failed: build/lib.linux-x86_64-3.6/_tkinter.cpython-36m-x86_64-linux-gnu.so: undefined symbol: Tcl_GetCharLength

    Following modules built successfully but were removed because they could not be imported:
    _tkinter

    Any Idea's on how to fix the undefined symbol error? This happens with both Tcl/Tk 8.6.6 and 8.6.7.

    The following is the configure options:
    --prefix=/tools/apps/python/3.6.1 --with-tcltk-includes='-I/tools/apps/Tcl/8.6.7/include -I/tools/apps/Tk/8.6.7/include' --with-tcltk-libs='-L/tools/apps/Tcl/8.6.7/lib -L/tools/apps/Tk/8.6.7/lib' --enable-optimizations --enable-shared

  2. ned-deily commented on Oct 20, 2017

    @ned-deily
    Member

    You may need to set LD_LIBRARY_PATH env variable to point to your Tcl and Tk libraries or, better, add an rpath entry to LDFLAGS.

  3. jpc2350 commented on Oct 20, 2017

    jpc2350mannequin
    MannequinAuthor

    Hi Ned,

    LD_LIBRARY_PATH has been set with the lib paths for both, like I said the
    module itself builds, I’ll add the module build logs later but the module
    try’s to get loaded before the tests which unfortunately gives the error
    undefined symbol: Tcl_GetCharLength
    On Fri, 20 Oct 2017 at 20:57, Ned Deily <[email protected]> wrote:

    Ned Deily <[email protected]> added the comment:

    You may need to set LD_LIBRARY_PATH env variable to point to your Tcl and
    Tk libraries or, better, add an rpath entry to LDFLAGS.

    ----------
    nosy: +ned.deily


    Python tracker <[email protected]>
    <https://bugs.python.org/issue31817\>


  4. jpc2350 commented on Oct 23, 2017

    jpc2350mannequin
    MannequinAuthor

    Hi Ned,

    Please see the make logs for _tkinter below:

    building '_tkinter' extension
    gcc -pthread -fPIC -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -fprofile-generate -DWITH_APPINIT=1 -I./Include -I. -I/usr/include/x86_64-linux-gnu -I/usr/local/include -I/tools/src/Python-3.6.3/Include -I/tools/src/Python-3.6.3 -c /tools/src/Python-3.6.3/Modules/_tkinter.c -o build/temp.linux-x86_64-3.6/tools/src/Python-3.6.3/Modules/_tkinter.o -I/tools/apps/tcl/8.6.7/include -I/tools/apps/tk/8.6.7/include
    gcc -pthread -fPIC -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -fprofile-generate -DWITH_APPINIT=1 -I./Include -I. -I/usr/include/x86_64-linux-gnu -I/usr/local/include -I/tools/src/Python-3.6.3/Include -I/tools/src/Python-3.6.3 -c /tools/src/Python-3.6.3/Modules/tkappinit.c -o build/temp.linux-x86_64-3.6/tools/src/Python-3.6.3/Modules/tkappinit.o -I/tools/apps/tcl/8.6.7/include -I/tools/apps/tk/8.6.7/include
    gcc -pthread -shared -fprofile-generate -fprofile-generate build/temp.linux-x86_64-3.6/tools/src/Python-3.6.3/Modules/_tkinter.o build/temp.linux-x86_64-3.6/tools/src/Python-3.6.3/Modules/tkappinit.o -L. -L/usr/lib/x86_64-linux-gnu -L/usr/local/lib -lpython3.6m -o build/lib.linux-x86_64-3.6/_tkinter.cpython-36m-x86_64-linux-gnu.so -L/tools/apps/tcl/8.6.7/lib -L/tools/apps/tk/8.6.7/lib

  5. jpc2350 commented on Nov 2, 2017

    jpc2350mannequin
    MannequinAuthor

    LD_LIBRARY_PATH includes /tools/apps/tk/8.6.7/lib/:/tools/apps/tcl/8.6.7/lib/
    and several other library paths that are required.

    Why would I be getting an undefined symbol error on this module?
    _tkinter.cpython-36m-x86_64-linux-gnu.so: undefined symbol: Tcl_GetCharLength

    I've even tried added g++ as an option, but Python fails to be against this: bpo-23644

    I'm stuck now, and this is causing real problems for some pipelines that I'm trying to get running.

  6. ned-deily commented on Nov 3, 2017

    @ned-deily
    Member

    Josh, sorry I don't have any further ideas off the top of my head and I likely won't have time for several weeks to try to reproduce this myself. Have you tried renaming the _tkinter extension back, doing a "make install", and seeing whether it imports properly from the installed python?

  7. jpc2350 commented on Nov 15, 2017

    jpc2350mannequin
    MannequinAuthor

    Hi Ned,

    Tried that but unfortunately it didn't work. It still produces an error within the make install function which then re-removes the module - it does however create a folder called tkinter.

  8. jpc2350 commented on Nov 28, 2017

    jpc2350mannequin
    MannequinAuthor

    Hi Ned,

    I've built a new machine, tried the build again using Tk and Tcl shared libraries, built Python-3.6.3 and it's still not worked.

    The Python/3.6.3-foss-2017b/lib/python3.6/tkinter folder gets created and populated with several files, but when you try and import tkinter in python, it fails to import with:

    >>> import tkinter
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/tools/apps/Python/3.6.3-foss-2017b/lib/python3.6/tkinter/__init__.py", line 36, in <module>
        import _tkinter # If this fails your Python may not be configured for Tk
    ModuleNotFoundError: No module named '_tkinter'

    Running __init__.py from the tkinter folder produces this output:

    Traceback (most recent call last):
      File "__init__.py", line 36, in <module>
        import _tkinter # If this fails your Python may not be configured for Tk
    ModuleNotFoundError: No module named '_tkinter'

    I'm guessing something is failing to build correctly but it's not being logged.

    Both Tk and Tcl versions 8.6.6 and 8.6.7 are available and working on the system.

  9. StarkBjorn commented on Mar 29, 2018

    StarkBjornmannequin
    Mannequin

    Python 3.6.4
    tcl8.6.5+dfsg-2
    tk8.6.5-1

    The problem:

    *** WARNING: renaming "_tkinter" since importing it failed: build/lib.linux-x86_64-3.6/_tkinter.cpython-36m-x86_64-linux-gnu.so: undefined symbol: Tcl_GetCharLength

    still remains!

  10. dplusplus commented on May 11, 2018

    dplusplusmannequin
    Mannequin

    I am trying to build Python 3.6.5 from source, with Tcl 8.6.8 and Tk 8.6.8, and I get the same issue (Building on Ubuntu 18.04, tried with GCC 7.3 and 8.1 with same results).
    Run 'readelf -d` on 'build/lib.linux-x86_64-3.6/_tkinter.cpython-36m-x86_64-linux-gnu_failed.so' and I get three NEEDED entries:

    0x0000000000000001 (NEEDED) Shared library: [libpython3.6m.so.1.0]
    0x0000000000000001 (NEEDED) Shared library: [libpthread.so.0]
    0x0000000000000001 (NEEDED) Shared library: [libc.so.6]

    Tcl and Tk libraries are not listed as needed shared libraries, which explains why settings runpaths (which I tried by setting CFLAGS) does not seem to work.
    I'm comparing this to the ELF entries in Ubuntu's Python 3.6.5 tkinter module '/usr/lib/python3.6/lib-dynload/_tkinter.cpython-36m-x86_64-linux-gnu.so', which does have NEEDED entries for tcl8.6.so and tk8.6.so.

  11. dplusplus commented on Jun 18, 2018

    dplusplusmannequin
    Mannequin

    Revisited this recently and found a fix. This problem seems to appear only if Tcl and/or Tk is installed in a non-standard folder.

    In the ./configure call, include -ltcl8.6 -ltk8.6 (for Tcl/Tk 8.6.x) in the --with-tcltk-libs specification, so the command looks like ./configure --with-tcltk-libs='-L/path/to/tcl/lib/location -L/path/to/tk/lib/location -ltcl8.6 -ltk8.6'. Since the Tcl and Tk shared libraries are in non-standard locations, set LD_LIBRARY or append '-Wl,-rpath,/path/to/tcl/lib/location -Wl,-rpath,/path/to/tk/lib/location' to --with-tcltk-libs. Run make and the tkinter import failure is no longer there.

    import tkinter runs fine, but an error appears when running the simple hello world script at https://docs.python.org/3.6/library/tkinter.html:

    Traceback (most recent call last):
      File "/opt/tk_sample.py", line 22, in <module>
        root = tk.Tk()
      File "/opt/Python-3.6.5/Lib/tkinter/__init__.py", line 2020, in __init__
        self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
    _tkinter.TclError: Can't find a usable tk.tcl in the following directories:
        /opt/tk/lib /opt/tcl/lib/tcl8.6/tk8.6 /opt/tcl/lib/tk8.6 /opt/Python-3.6.5/lib/tk8.6 /opt/Python-3.6.5/lib/tk8.6 /opt/lib/tk8.6 /opt/Python-3.6.5/library

    tk.tcl is in /opt/tk/lib/tk8.6; looking at the directories listed in the error message _tkinter is expecting Tcl and Tk to be installed in the same folder (To be fair, Tk warns about this in its configure script).
    This is fixed by setting the environment variable TK_LIBRARY to the folder where tk.tcl is. I do not consider this a complete solution though, since TK_LIBRARY needs to be set to run anything that uses tkinter.

  12. zhang commented on May 29, 2020

    zhangmannequin
    Mannequin

    Josh,Did you solve this problem?I met the same error when install python.

    *** WARNING: renaming "_tkinter" since importing it failed: build/lib.linux-x86_64-3.6/_tkinter.cpython-36m-x86_64-linux-gnu.so: undefined symbol: Tcl_GetCharLength

  13. ned-deily commented on May 29, 2020

    @ned-deily
    Member

    @Zhang, Did you try the solution given by dplusplus in the previous message (msg319861)?

  14. iritkatriel commented on Jan 21, 2022

    @iritkatriel
    Member

    3.6 is no longer maintained. Is this a problem on current versions or can be close this?

  15. transferred this issue fromon Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions