Python IDLE 未在 Windows 7 上启动

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3488256/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-18 11:20:13  来源:igfitidea点击:

Python IDLE is not starting on Windows 7

pythonwindows-7python-idle

提问by didideder

I used to use Python 2.7 and then IDLE was working. I uninstalled it and installed Python 3.1.
Right now Idle cannot launch. What should i do to get it running?

我曾经使用 Python 2.7,然后 IDLE 就可以工作了。我卸载了它并安装了 Python 3.1。
现在空闲无法启动。我该怎么做才能让它运行?

NOTE: I tried c:\Python31\pythonw.exe c:\Python31\Lib\idlelib\idle.py
i uninstalled 3.1 and installed back 2.7, not working neither...

注意:我试过 c:\Python31\pythonw.exe c:\Python31\Lib\idlelib\idle.py
我卸载了 3.1 并重新安装了 2.7,也不起作用......

采纳答案by Alex Martelli

In the past, I've often found that when I had some issues with the python.orgversion of some Python release, specifically on Windows, installing instead the activepythonversion of the same release, from ActiveState, made the problems go away. So, in your shoes, the first thing I would try would be ActivePython (I don't think they have a 2.7 yet -- it's probably been around for too short a time yet -- but they definitely do have a 3.1).

过去,我经常发现当我在某些python.orgPython 版本的版本上遇到一些问题时,特别是在 Windows 上,从 ActiveState安装相同版本的activepython版本,可以使问题消失。因此,在您看来,我首先要尝试的是 ActivePython(我认为他们还没有 2.7 版本——它可能推出的时间太短了——但他们肯定有 3.1 版本)。

EDIT: Versions 2.5, 2.6, 2.7, 3.2, 3.3, and 3.4 have been added.

编辑:已添加版本 2.5、2.6、2.7、3.2、3.3 和 3.4。

回答by Jasim

I too faced the same problem. But at last solved like this -->

我也面临同样的问题。但最后是这样解决的-->

Run Python\Lib\idlelib\idle.py as admin, i got the error that the file "recent-files.lst" can't be opened.

以管理员身份运行 Python\Lib\idlelib\idle.py,我收到无法打开文件“recent-files.lst”的错误。

So go to your home folder, show hidden files, click on .idlerc and delete the file named "recent-files". Now IDLE is working...

因此,转到您的主文件夹,显示隐藏文件,单击 .idlerc 并删除名为“recent-files”的文件。现在空闲正在工作......

回答by Nagrom

I ran into this weird situation also, and did a bit of troubleshooting. As a rigorous task, uninstalling, and re-installing the versions of python(2.6, 2.7, 3.1) and all my associated extensions and other site packages: in addition to the subsequent options that others have provided, that may have, or may not have, helped fix issues with the IDLE working properly. I found and error on my part, installing a 32 bit .msi on a 64 bit system causes a runtime .dll error with tkinter and therfore, causes IDLE to not start up properly, or not at all. Be mindful, and don't be a blind bat like me... :)

我也遇到了这种奇怪的情况,并进行了一些故障排除。作为一项严格的任务,卸载并重新安装 python(2.6, 2.7, 3.1) 版本以及我所有相关的扩展和其他站点包:除了其他人提供的后续选项之外,可能有,也可能没有已经帮助解决了 IDLE 正常工作的问题。我发现我的部分错误,在 64 位系统上安装 32 位 .msi 会导致 tkinter 的运行时 .dll 错误,因此导致 IDLE 无法正常启动,或根本无法启动。注意,不要像我一样盲目... :)

回答by Scott_Wang

Just try to delete the files which end with .idlercin your profile.

只需尝试删除.idlerc以您的个人资料结尾的文件。

1. Enter <win-r>, and type %USERPROFILE%\.idlerc
2. delete all files in idlerc folder
3. it works on my PC(win7 OS)

回答by Bogdan Baudis

My system is Win7/64 Enterprise edition and the Python version is 2.7.3 (I need this one...). This is what I got when I ran idle.py from the command window:

我的系统是Win7/64企业版,Python版本是2.7.3(我需要这个...)。这是我从命令窗口运行 idle.py 时得到的:

"
C:\Python27\Lib\idlelib>idle.py
Traceback (most recent call last):
  File "C:\Python27\Lib\idlelib\idle.py", line 11, in <module>
    idlelib.PyShell.main()
  File "C:\Python27\Lib\idlelib\PyShell.py", line 1406, in main
    root = Tk(className="Idle")
  File "C:\Python27\lib\lib-tk\Tkinter.py", line 1685, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, want
objects, useTk, sync, use)
_tkinter.TclError: Can't find a usable init.tcl in the following directories:
    {C:\Program Files (x86)\CSR\BlueSuite 2.5.0} C:/Python27/lib/tcl8.5 C:/lib/t
cl8.5 C:/lib/tcl8.5 C:/library C:/library C:/tcl8.5.2/library C:/tcl8.5.2/librar
y

This probably means that Tcl wasn't installed properly.
"

Indeed there was no "tcl8.5" folder in any of the listed above place but it was under: "C:\Python27\tcl".

事实上,上面列出的任何地方都没有“tcl8.5”文件夹,但它在:“C:\Python27\tcl”下。

When I copied it under "C:\Python27\lib" then IDLE started (with some other warnings but this seems related to my corp environment...)

当我将它复制到“C:\Python27\lib”下时,IDLE 启动(还有一些其他警告,但这似乎与我的公司环境有关......)

In conclusion this looks like either an installer failing to copy the folder where it is supposed to or failing to set up some environment variables correctly or there's an actual bug int the release likely to show up on Win7/64 on certain edition(s). I am not a Python expert enough to debug Python itself, so please somebody take it from here...in the meantime I will see if the "workaround" is good enough :-)

总而言之,这看起来像是安装程序未能将文件夹复制到它应该复制的位置或未能正确设置某些环境变量,或者在某些版本的 Win7/64 上可能会出现发行版中的实际错误。我不是 Python 专家,不足以调试 Python 本身,所以请有人从这里拿走它......同时我会看看“解决方法”是否足够好:-)

回答by uli

Run python setup program, change python 2x, choose to entirely remove tcl/tk, proceed, then run setup again, change python again, on the tcl\tk choose entire feature will be installed, proceed.

运行python安装程序,更改python 2x,选择完全删除tcl/tk,继续,然后再次运行安装程序,再次更改python,在tcl\tk上选择将安装整个功能,继续。

It worked for me.

它对我有用。

回答by smasher

I got the same problem on window 10. Steps to solve the problem:

我在窗口 10 上遇到了同样的问题。解决问题的步骤:

  1. Locate the .idlercfolder in your profile directory (e.g. C:\Users\{your-username}without the braces).
  2. Delete the .idlercdirectory.
  1. .idlerc在您的配置文件目录中找到该文件夹(例如,C:\Users\{your-username}没有大括号)。
  2. 删除.idlerc目录。

It worked for me...

它对我有用...

回答by Todd Meyers

Once I copied the C:\Python27\tcl\tcl8.5folder to C:\Python27\Libas suggested in Bogdan's answer the error message "This probably means that Tcl wasn't installed properly"went away. Instead I started seeing "This probably means that tk wasn't installed properly". I had to copy the C:\Python27\tcl\tk8.5folder to C:\Python27\Libas well. Once I did that running idle.pyfrom the command line in C:\Python27\Lib\idlelibwas error-free.

一旦我按照 Bogdan 的回答中的建议将C:\Python27\tcl\tcl8.5文件夹复制到C:\Python27\Lib,错误消息"This probably means that Tcl wasn't installed properly"就消失了。相反,我开始看到"This probably means that tk wasn't installed properly". 我也必须将C:\Python27\tcl\tk8.5文件夹复制到C:\Python27\Lib。一旦我这样做了,idle.py从命令行运行就没有C:\Python27\Lib\idlelib错误了。

回答by Ashish Ranjan

Even I was facing same issue with my code, But It is resolved now. I was using 2.6 which was having old version of Xlrd, so I updated xlrd in 2.7 using pip and I opened my file with 2.7 and it works.

即使我的代码也面临同样的问题,但现在已经解决了。我使用的是 2.6,它有旧版本的 Xlrd,所以我使用 pip 在 2.7 中更新了 xlrd,我用 2.7 打开了我的文件,它可以工作。

回答by Belial

Delete the .idlerc directory as suggested above, run the python installer again and choose repair. If needed associate the .py files with the python.exe executable in Python27 folder. This worked for me after removing python 3.7.

按照上面的建议删除 .idlerc 目录,再次运行 python 安装程序并选择修复。如果需要,将 .py 文件与 Python27 文件夹中的 python.exe 可执行文件相关联。删除python 3.7后,这对我有用。