You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Compilation Error with Python 3.6.1/3.6.3 with Tkinter #75998
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=Noneclosed_at=<Date2022-01-30.16:51:17.463>created_at=<Date2017-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=<Date2022-01-30.16:51:17.463>user='https://github.com/jpc2350'
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
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.
jpc2350 commented on Oct 20, 2017
jpc2350mannequin
MannequinAuthor
More actions
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:
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?
jpc2350 commented on Nov 15, 2017
jpc2350mannequin
MannequinAuthor
More actions
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.
jpc2350 commented on Nov 28, 2017
jpc2350mannequin
MannequinAuthor
More actions
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.
>>> 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 TkModuleNotFoundError: 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.
StarkBjorn commented on Mar 29, 2018
StarkBjornmannequin
Mannequin
More actions
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!
dplusplus commented on May 11, 2018
dplusplusmannequin
Mannequin
More actions
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:
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.
dplusplus commented on Jun 18, 2018
dplusplusmannequin
Mannequin
More actions
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.
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.
zhang commented on May 29, 2020
zhangmannequin
Mannequin
More actions
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
Activity
jpc2350 commentedon Oct 19, 2017
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
ned-deily commentedon Oct 20, 2017
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.
jpc2350 commentedon Oct 20, 2017
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:
jpc2350 commentedon Oct 23, 2017
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
jpc2350 commentedon Nov 2, 2017
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.
ned-deily commentedon Nov 3, 2017
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?
jpc2350 commentedon Nov 15, 2017
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.
jpc2350 commentedon Nov 28, 2017
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:
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.
StarkBjorn commentedon Mar 29, 2018
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!
dplusplus commentedon May 11, 2018
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.
dplusplus commentedon Jun 18, 2018
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 tkinterruns fine, but an error appears when running the simple hello world script at https://docs.python.org/3.6/library/tkinter.html:tk.tclis 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.
zhang commentedon May 29, 2020
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
ned-deily commentedon May 29, 2020
@Zhang, Did you try the solution given by dplusplus in the previous message (msg319861)?
iritkatriel commentedon Jan 21, 2022
3.6 is no longer maintained. Is this a problem on current versions or can be close this?