Why my Python installed via home brew not include Tkinter

后端 未结 6 1920
粉色の甜心
粉色の甜心 2020-12-02 20:21

I\'ve installed my Python via homebrew on Mac.

brew install python

and after that I\'ve checked my python version as 2.7.11, then I\'ve tri

相关标签:
6条回答
  • 2020-12-02 20:59

    12/18 Update: No longer possible for various reasons.

    Below is now outdated. You'll have to install Python directly from python.org if you want to remove those warnings.


    2018 Update

    brew reinstall python --with-tcl-tk
    

    Note: Homebrew now uses Python 3 by default - Homebrew Blog. Docs.


    Testing

    python should bring up system’s Python 2, python3 should bring up Python 3.

    idle points to system Python/tcl-tk. It will show an out-dated tcl-tk error (unless you brew install python@2 --with-tcl-tk)

    idle3 should bring up Python 3 with no warnings.

    Caveat

    --with-tcl-tk will install python directly from python.org, which you'll see when you run brew info python.

    More info here.

    0 讨论(0)
  • 2020-12-02 21:01

    On mac OSX you must install TCL separately:

    You will find instructions and dowloadables here: https://www.tcl.tk/software/tcltk/ and there: http://wiki.tcl.tk/1013

    It requires a little bit of effort, but it is neither complicated nor difficult.

    0 讨论(0)
  • 2020-12-02 21:04

    It may be because you don't have the latest Xcode command line tools so brew built python from source instead of from bottle. Try:

    xcode-select --install
    brew uninstall python
    brew install python --use-brewed-tk
    
    0 讨论(0)
  • 2020-12-02 21:05

    If you're using pyenv you can try installing tcl-tk via homebrew and then activating the env. vars. mentioned in its caveats section, as detailed in this answer. Activating those env. vars. prior to installing python via homebrew may work for you:

    ※ export PATH="/usr/local/opt/tcl-tk/bin:$PATH"
    ※ export LDFLAGS="-L/usr/local/opt/tcl-tk/lib"
    ※ export CPPFLAGS="-I/usr/local/opt/tcl-tk/include"
    ※ export PKG_CONFIG_PATH="/usr/local/opt/tcl-tk/lib/pkgconfig"
    ※ brew reinstall python
    
    0 讨论(0)
  • 2020-12-02 21:08

    Based on the comments from above and the fact that Python must be linked to Tcl/Tk framework:

    If you don't have Xcode command line tools, install those:

    xcode-select --install
    

    If you don't have Tcl/Tk brew installation (check brew list), install that:

    brew install tcl-tk
    

    Then, run "brew uninstall python" if that was not installed with option --with-tcl-tk (the current official option). Then install Python again, linking it to the brew installed Tcl/Tk:

    brew install python --with-tcl-tk
    
    0 讨论(0)
  • 2020-12-02 21:09

    It is a bit more complicated now, true you still need to have xcode command line tools and homebrew as a start. But the procedure changes constantly. Homebrew took out tcl-tk support long ago, and apple still only supplies v8.5 of tcl-tk. Anyway, it is possible, and I maintain a github gist personally to fix these issues.

    Latest update is using python 3.8.1 (will probably be usable on the 3.8.x branch later too) see here, just follow the steps outlined. github gist link to install tcl-tk with python

    0 讨论(0)
提交回复
热议问题