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

Can't build _tkinter module using brew install on Mac OS X #93659

Closed
izumiberat opened this issue Jun 9, 2022 · 5 comments
Closed

Can't build _tkinter module using brew install on Mac OS X #93659

izumiberat opened this issue Jun 9, 2022 · 5 comments
Labels
docs Documentation in the Doc dir OS-mac

Comments

@izumiberat
Copy link

izumiberat commented Jun 9, 2022

Documentation
I am using Mac OS Catalina 10.15.7.
I am getting the following message when following the documentation here: https://devguide.python.org/setup/#install-dependencies and running make -s -j2

Python build finished successfully!
The necessary bits to build these optional modules were not found:
_tkinter
To find the necessary bits, look in setup.py in detect_modules() for the module's name.

I tried running brew install python-tk, but it didn't resolve the issue. Any ideas?

PR python/devguide#893

@izumiberat izumiberat added the docs Documentation in the Doc dir label Jun 9, 2022
@erlend-aasland
Copy link
Contributor

erlend-aasland commented Jun 10, 2022

First, the python-tk Homebrew package is not the Tcl/Tk headers and libraries. If you want those, you need to install the tcl-tk package:

$ brew update && brew install tcl-tk

Since Python 3.11, configure uses pkg-config to detect Tcl/Tk. Try this:

# install pkg-config
$ brew update && brew install pkg-config

# assuming you now have pkg-config in your path, and you´ve installed the tcl-tk brew:
$ PKG_CONFIG_PATH="$(brew --prefix tcl-tk)/lib/pkgconfig" ./configure
$ make

@erlend-aasland erlend-aasland added the pending The issue will be closed if no feedback is provided label Jun 10, 2022
@izumiberat
Copy link
Author

@erlend-aasland this is great thanks. It resolved the issue with the only caveat that Python build finished successfully! doesn't show anymore.

One question: for this to work when following the documentation, I ran the command line you provided with this in addition: --with-pydebug --with-openssl=$(brew --prefix openssl) (as it is indicated in the documentation)

The command line I ran is:

PKG_CONFIG_PATH="$(brew --prefix tcl-tk)/lib/pkgconfig" ./configure --with-pydebug --with-openssl=$(brew --prefix openssl)

Is it ok to have such a long command line? I am asking because I would suggest this line as an update to the documentation to be able to build _tkinter.


One more question, is it ok/normal for the message:

Python build finished successfully!

not to show after compiling make -s -j2?

It used to appear just before the message below that is not showing anymore (resolving therefore the current issue I opened):

The necessary bits to build these optional modules were not found:
_tkinter
To find the necessary bits, look in setup.py in detect_modules() for the module's name.

Below the full message I get after running make -s -j2:

Note: Deepfreeze may have added some global objects,
so run 'make regen-global-objects' if necessary.
/Library/Developer/CommandLineTools/usr/bin/ranlib: file: libpython3.12d.a(dynamic_annotations.o) has no symbols
/Library/Developer/CommandLineTools/usr/bin/ranlib: file: libpython3.12d.a(pymath.o) has no symbols
CC='gcc' LDSHARED='gcc -bundle -undefined dynamic_lookup ' OPT='-g -Og -Wall' ./python.exe -E ./setup.py -q build
ld: warning: directory not found for option '-L/usr/lib/termcap'
renaming build/scripts-3.12/pydoc3 to build/scripts-3.12/pydoc3.12
renaming build/scripts-3.12/idle3 to build/scripts-3.12/idle3.12
renaming build/scripts-3.12/2to3 to build/scripts-3.12/2to3-3.12


One final question: how do you add color to your comments??

@erlend-aasland
Copy link
Contributor

@erlend-aasland this is great thanks.

Great, so we close this issue! Glad to help 🙂

It resolved the issue with the only caveat that Python build finished successfully! doesn't show anymore.

It seems like that message is only printed if there are missing modules 😆 I guess we should change that; thanks for the heads-up, I'll follow it up.

The command line I ran is:

PKG_CONFIG_PATH="$(brew --prefix tcl-tk)/lib/pkgconfig" ./configure --with-pydebug --with-openssl=$(brew --prefix openssl)

Is it ok to have such a long command line?

Yes. You can split it up over multiple lines to make it more readable. Here's my command line to build Python (part of my build-python.sh script):

PKG_SQLITE="$PREFIX/$SQLITE/lib/pkgconfig"
PKG_TCLTK="$(brew --prefix tcl-tk)/lib/pkgconfig"

PKG_CONFIG_PATH="$PKG_SQLITE:$PKG_TCLTK:$PKG_CONFIG_PATH" \
"$TREE/configure" -C \
  --prefix="$HOME/install" \
  --with-openssl=$(brew --prefix openssl@3) \
  CC="$CC" \
  CFLAGS="$CFLAGS" \
  LDFLAGS="$LDFLAGS" \
  $ENABLE_OPTIMIZATIONS \
  $ENABLE_LOAD_EXT \
  $PYDEBUG
make $MAKE_TARGET

(Most of the helper variables are set up earlier in the build script.)

I am asking because I would suggest this line as an update to the documentation to be able to build _tkinter.

That's a very good idea. There's already a PR up regarding this; you could chime in there: python/devguide#891

One final question: how do you add color to your comments??

GitHub Markdown

For the command examples in my previous post, I used three backticks fencing with the console highlighting keyword:

    ```console
    $ brew update ... etc.
    ```

@izumiberat
Copy link
Author

@erlend-aasland great thanks very much for your help. For the markdown, I can now see that colors are rendered automatically. I believe there is no way to add colors ourselves. Yes, I created the PR you refer to. I updated it earlier today and it is not relevant anymore to this issue, but I will create a new PR, and link it to this issue for reference.

@erlend-aasland
Copy link
Contributor

Yeah, the colours are rendered automatically, but you've got a lot of different highlighting keywords to choose from (python, c, json, bash, etc.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir OS-mac
Projects
None yet
Development

No branches or pull requests

4 participants