Opened 14 years ago

Closed 10 years ago

#25221 closed defect (fixed)

"import Tkinter" fails in python26 @2.6.5_1 with 64-bit tk @8.5.8+quartz

Reported by: jabronson@… Owned by: macports-tickets@…
Priority: Normal Milestone:
Component: ports Version: 1.9.0
Keywords: Cc: blb@…, MarcusCalhoun-Lopez (Marcus Calhoun-Lopez), andreas@…, jyrkiwahlstedt, erickt@…, ryandesign (Ryan Carsten Schmidt)
Port: python26 python27 python31

Description

A few months ago I built 64-bit Macports tk +quartz (using the fix from #20799), after which I was able to use the Tkinter module of Macports python26 (then @2.6.4) to create native Aqua windows. I just tried "import Tkinter" for the first time in a while and now I get:

Python 2.6.5 (r265:79063, Jun 12 2010, 12:43:44) 
[GCC 4.2.1 (Apple Inc. build 5646) (dot 1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import Tkinter
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk/Tkinter.py", line 39, in <module>
    import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named _tkinter

As you can see, I've since upgraded to Python 2.6.5. I just tried building Macports Python 2.6.5 again and sure enough, I noticed this output:

...
building '_tkinter' extension
/usr/bin/gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DWITH_APPINIT=1 -I. -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_python26/work/Python-2.6.5/./Include -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_python26/work/Python-2.6.5/./Mac/Include -I/opt/local/Library/Frameworks/Python.framework/Versions/2.6/include -I. -IInclude -I./Include -I/opt/local/include -I/opt/local/include/ncurses -I/usr/local/include -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_python26/work/Python-2.6.5/Include -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_python26/work/Python-2.6.5 -c /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_python26/work/Python-2.6.5/Modules/_tkinter.c -o build/temp.macosx-10.6-x86_64-2.6/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_python26/work/Python-2.6.5/Modules/_tkinter.o
/usr/bin/gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DWITH_APPINIT=1 -I. -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_python26/work/Python-2.6.5/./Include -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_python26/work/Python-2.6.5/./Mac/Include -I/opt/local/Library/Frameworks/Python.framework/Versions/2.6/include -I. -IInclude -I./Include -I/opt/local/include -I/opt/local/include/ncurses -I/usr/local/include -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_python26/work/Python-2.6.5/Include -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_python26/work/Python-2.6.5 -c /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_python26/work/Python-2.6.5/Modules/tkappinit.c -o build/temp.macosx-10.6-x86_64-2.6/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_python26/work/Python-2.6.5/Modules/tkappinit.o
/usr/bin/gcc-4.2 -L/opt/local/lib -arch x86_64 -bundle -undefined dynamic_lookup build/temp.macosx-10.6-x86_64-2.6/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_python26/work/Python-2.6.5/Modules/_tkinter.o build/temp.macosx-10.6-x86_64-2.6/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_python26/work/Python-2.6.5/Modules/tkappinit.o -L/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib -L/opt/local/lib -L/usr/local/lib -ltk8.5 -ltcl8.5 -lX11 -o build/lib.macosx-10.6-x86_64-2.6/_tkinter.so
ld: library not found for -lX11
collect2: ld returned 1 exit status
...
Failed to build these modules:
_tkinter                                              
...

It looks like it's mistakenly passing "-lX11" when it's trying to build _tkinter.so. Am I correct in suspecting that since my tk is built with +quartz, libX11 should not be involved in building _tkinter? Is there a way to fix this?

I'm running Macports 1.9.0 and OS X 10.6.3.

Thanks! Josh

Change History (7)

comment:1 Changed 14 years ago by jmroot (Joshua Root)

Why do you think this is a bug in python26 and not in your modified tk port?

comment:2 in reply to:  1 Changed 14 years ago by jabronson@…

Replying to jmr@…:

Why do you think this is a bug in python26 and not in your modified tk port?

I gave all the information I have. Feel free to correct anything that may be incorrect.

comment:3 Changed 14 years ago by blb@…

Cc: jwa@… erickt@… added; mww@… removed
Port: python27 python31 added

Fixed in r68792; however you're going to run into #22954 since the tcl port does not currently link to CoreFoundation.

Cc'ing 2.7 and 3.1 maintainers as this is probably needed for those as well.

comment:4 Changed 14 years ago by jabronson@…

Rebuilt tcl with the patch from #22954 and then rebuilt python26 from svn and Tkinter now works like a charm, thanks!!!

comment:5 in reply to:  3 ; Changed 14 years ago by ryandesign (Ryan Carsten Schmidt)

Cc: ryandesign@… added

Replying to blb@…:

Fixed in r68792

On my Leopard ppc machine with MP 1.9.0 I now get:

$ port -u upgrade python26
--->  Computing dependencies for python26
--->  Fetching python26
--->  Verifying checksum(s) for python26
--->  Extracting python26
--->  Applying patches to python26
Error: Target org.macports.patch returned: wrong # args: should be "catch command ?varName?"
Log for python26 is at: /mp/var/macports/logs/_Volumes_data_macports_ports_lang_python26/main.log
Error: Unable to upgrade port: 1

AFAICT this "options" parameter you're using was only added in TCL 8.5; Leopard has TCL 8.4.

comment:6 in reply to:  5 Changed 14 years ago by blb@…

Replying to ryandesign@…:

AFAICT this "options" parameter you're using was only added in TCL 8.5; Leopard has TCL 8.4.

Oops, that is right; fortunately I wasn't using either variable in the catch anyway, so it should work on older Tcl as of r68800.

comment:7 Changed 10 years ago by jmroot (Joshua Root)

Resolution: fixed
Status: newclosed

Seems fine with current versions.

Note: See TracTickets for help on using tickets.