如何在 Windows 上 pip 或 easy_install tkinter [英] How to pip or easy_install tkinter on Windows
问题描述
My Idle 抛出错误,提示 tkinter
无法导入.
有没有一种通过 pip
或 easy_install
安装 tkinter
的简单方法?
似乎有很多包名称为此而四处飞扬...
这个和其他带有 tkinter-pypy
的各种变体都不起作用.
pip install python-tk
我在使用 Python 2.7 的 Windows 上,我没有 apt-get
或其他系统包管理器.
好吧,我可以在这里看到两个解决方案:
1) 遵循 Docs-Tkinter for Python 安装(适用于 Windows):
Tkinter(以及自 Python 3.1 起,ttk)包含在所有标准 Python 发行版中.使用支持 Tk 8.5 或更高版本的 Python 版本以及 ttk 非常重要.我们建议从 ActiveState 安装ActivePython"发行版,其中包含您需要的一切.
在您的网络浏览器中,转到 Activestate.com,然后按照链接下载社区版适用于 Windows 的 ActivePython.确保您下载的是 3.1 或更新版本,而不是 2.x 版本.
运行安装程序,然后继续.您最终将获得全新安装的 ActivePython,位于例如C:python32
.从 Windows 命令提示符或开始菜单的运行..."命令,您应该能够通过以下方式运行 Python shell:
% C:python32python
这应该会为您提供 Python 命令提示符.在提示符下,输入以下两个命令:
<预><代码>>>>导入 tkinter>>>tkinter._test()这应该会弹出一个小窗口;窗口顶部的第一行应该说这是 Tcl/Tk 8.5 版";确保它不是 8.4!
2) 卸载 64 位 Python 并安装 32 位 Python.
My Idle is throwing errors that and says tkinter
can't be imported.
Is there a simple way to install tkinter
via pip
or easy_install
?
There seem to be a lot of package names flying around for this...
This and other assorted variations with tkinter-pypy
aren't working.
pip install python-tk
I'm on Windows with Python 2.7 and I don't have apt-get
or other system package managers.
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:python32python
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.
这篇关于如何在 Windows 上 pip 或 easy_install tkinter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!