无法打开 Python 闲置

Can't Open Python IDLE

当我尝试打开 Python IDLE 时,在控制台中以 9 个单独的屏幕打开以下代码。据我所知,我对原始安装没有做任何事情。有任何想法吗?尝试卸载并重新安装但没有运气。打开程序时显示的代码是...

try:
    import idlelib.PyShell
except ImportError:
    # IDLE is not installed, but maybe PyShell is on sys.path:
    try:
        from . import PyShell
    except ImportError:
        raise
    else:
        import os
        idledir = os.path.dirname(os.path.abspath(PyShell.__file__))
        if idledir != os.getcwd():
            # We're not in the IDLE directory, help the subprocess find run.py
            pypath = os.environ.get('PYTHONPATH', '')
            if pypath:
                os.environ['PYTHONPATH'] = pypath + ':' + idledir
            else:
                os.environ['PYTHONPATH'] = idledir
        PyShell.main()
else:
    idlelib.PyShell.main()

我只能选择关闭此 window 而不能创建新的 Python 文件。

我是 Idle 的维护者,非常不清楚您是如何尝试打开 Idle 的,您所说的“9 个屏幕”是什么意思,您 're-installed' 是什么系统,[=31 是什么系统和版本=].

安装 Python 后启动 Idle 的最简单方法是使用“开始”菜单图标(在 Windows 上)或其他系统上的等效图标。在命令行上,使用 python -m idlelib,其中 python 启动已安装的某些版本 3.x。对于已卸载的 3.x 或 2.x,请使用 idlelib.idle。从 Python 开始,import idlelib.idle 开始空闲。

如果您正确安装了 python 2.7 或 3.4 并且 运行ning,那么 python -m test.regrtest 运行 和通过(只需要 .regrtest对于 2.x),如果 Idle 没有使用上述方法运行,我会感到非常惊讶。

您发布的代码是idlelib/idle.pyw。它由 idlelib/idle.bat 使用,并且可能有其他专门用途,例如 运行ning Idle with a subprocess call。我怀疑它部分已过时。无论如何,我怀疑它对你有帮助。