如何在Windows上pip或easy_install tkinter [英] How to pip or easy_install tkinter on Windows

查看:106
本文介绍了如何在Windows上pip或easy_install tkinter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的空闲状态抛出错误,提示无法导入tkinter.

是否有通过pipeasy_install安装tkinter的简单方法?

为此,似乎有很多软件包名称出现了.

此以及其他tkinter-pypy的变体形式无效.

pip install python-tk

我在使用Python 2.7的Windows上,但不能apt-get.

谢谢.

解决方案

在这里我可以看到两种解决方案:

1)按照为Python安装Docs-Tkinter (对于Windows, ):

Tkinter(以及从Python 3.1开始的ttk)已包含在所有标准Python发行版中.使用支持Tk 8.5或更高版本以及ttk的Python版本很重要.我们建议从ActiveState安装"ActivePython"发行版,其中包括您需要的所有内容.

在您的网络浏览器中,转到 Activestate.com ,然后按照链接下载社区版Windows的ActivePython版本.确保您下载的是3.1或更高版本,而不是2.x版本.

运行安装程序,然后继续.最后,您将获得全新的ActivePython安装,例如位于C:\python32.从Windows命令提示符或开始"菜单的运行..."命令,您应该能够通过以下方式运行Python Shell:

% C:\python32\python

这应该给您Python命令提示符.在提示符下,输入以下两个命令:

>>> import 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 can't apt-get.

Thanks.

解决方案

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.

这篇关于如何在Windows上pip或easy_install tkinter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆