How to pip or easy_install tkinter on Windows

前端 未结 12 750
你的背包
你的背包 2020-11-28 22:31

My Idle is throwing errors that and says tkinter can\'t be imported.

Is there a simple way to install tkinter via pip or

相关标签:
12条回答
  • 2020-11-28 22:38

    Well I can see two solutions here:

    1) Follow the Docs-Tkinter install for Python (for Windows):

    Tkinter (and, since Python 3.1, ttk) are included with all standard Python distributions. It is important that you use a version of Python supporting Tk 8.5 or greater, and ttk. We recommend installing the "ActivePython" distribution from ActiveState, which includes everything you'll need.

    In your web browser, go to Activestate.com, and follow along the links to download the Community Edition of ActivePython for Windows. Make sure you're downloading a 3.1 or newer version, not a 2.x version.

    Run the installer, and follow along. You'll end up with a fresh install of ActivePython, located in, e.g. C:\python32. From a Windows command prompt, or the Start Menu's "Run..." command, you should then be able to run a Python shell via:

    % C:\python32\python
    

    This should give you the Python command prompt. From the prompt, enter these two commands:

    >>> import tkinter
    >>> tkinter._test()
    

    This should pop up a small window; the first line at the top of the window should say "This is Tcl/Tk version 8.5"; make sure it is not 8.4!

    2) Uninstall 64-bit Python and install 32 bit Python.

    0 讨论(0)
  • 2020-11-28 22:41

    When you install python for Windows, use the standard option or install everything it asks. I got the error because I deselected tcl.

    0 讨论(0)
  • 2020-11-28 22:41

    I had the similar problem with Win-8 and python-3.4 32 bit , I got it resolved by downloading same version from python.org .

    Next step will be to hit the repair button and Install the Tk/tkinter Package or Just hit the repair. Now should get Python34/Lib/tkinter Module present. The import tkinter should work ..

    0 讨论(0)
  • 2020-11-28 22:41

    Easiest way to do this:

    cd C:\Users\%User%\AppData\Local\Programs\Python\Python37\Scripts> 
    pip install pythonds 
    

    Screenshot of installing

    0 讨论(0)
  • 2020-11-28 22:42

    If you are using virtualenv, it is fine to install tkinter using sudo apt-get install python-tk(python2), sudo apt-get install python3-tk(python3), and and it will work fine in the virtual environment

    0 讨论(0)
  • 2020-11-28 22:44

    In python, Tkinter was a default package, you can repair the installation and select Tcl/Tk. repair When you run this, DDL should be installed like so: enter image description here

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