简体   繁体   English

使用 AutoHotKey 打开 Python IDLE

[英]opening Python IDLE with AutoHotKey

I've been messing around with AutoHotKey, trying to create some useful shortcuts for myself.我一直在搞乱 AutoHotKey,试图为自己创建一些有用的快捷方式。 I can open file explorer, calculator, chrome, etc., but I haven't been able to write a program that opens Python IDLE.我可以打开文件资源管理器、计算器、chrome 等,但是我一直无法编写打开 Python IDLE 的程序。

My program says:我的程序说:

!t::
Run pythonw
return

I've tried pythonw.exe, python.exe, python, python3.exe, and a bunch of other combinations.我试过 pythonw.exe、python.exe、python、python3.exe 和一堆其他组合。 Any idea why it isn't working?知道为什么它不起作用吗? Thanks!谢谢!

So, your problem is that Python IDLE is different from pythonw.exe, python.exe, python, python3.exe.所以,您的问题是 Python IDLE 与 pythonw.exe、python.exe、python、python3.exe 不同。

Python IDLE is an IDE or Code Editor provided with python whereas pythonw.exe, python.exe, python, python3.exe are the python interpreter. Python IDLE is an IDE or Code Editor provided with python whereas pythonw.exe, python.exe, python, python3.exe are the python interpreter.

pythonw.exe - for executing python scripts without opening console window(Hidden) python OR python3.exe OR python3.exe - are the same, that is the normal python interpreter. pythonw.exe - 用于在不打开控制台窗口(隐藏)的情况下执行 python 脚本(隐藏) python 或 python3.exe 或 python3.exe - 是相同的,即普通的 python 解释器。

So to open IDLE you should execute the IDLE file not the interpreter.所以要打开 IDLE,你应该执行 IDLE 文件而不是解释器。

The path for IDLE(in Windows Computer) is usually: IDLE(在 Windows 计算机中)的路径通常是:

C:\Python39\Lib\idlelib\idle.bat

Here the Python version is 3.9 but it may be different in your case: Check for the version you installed by opening command prompt and typing :这里 Python 版本是 3.9,但在您的情况下可能会有所不同:通过打开命令提示符并键入来检查您安装的版本:

C:\>python --version
Python 3.9.1

Turning the info that Jaysmito provided into an AutoHotkey Script:将 Jaysmito 提供的信息转换为 AutoHotkey 脚本:

!t::
Run C:\Python39\Lib\idlelib\idle.bat
return

However, the Python39 part of the directory above will vary based on which version of python you have installed.但是,上面目录的Python39部分会根据您安装的 python 版本而有所不同。 To check which version of Python you are using, use the python --version command in a command prompt window.要检查您使用的是哪个版本的 Python,请在命令提示符 window 中使用python --version命令。 Then if your version of Python is not in the 3.9.* range, change the directory above to match your version.然后,如果您的 Python 版本不在3.9.*范围内,请更改上面的目录以匹配您的版本。

For example, if your version is in the 2.7.* range, your directory would be something like Run C:\Python27\Lib\idlelib\idle.bat , with the Python39 from above changed to Python27 .例如,如果您的版本在2.7.*范围内,您的目录将类似于Run C:\Python27\Lib\idlelib\idle.bat ,上面的Python39更改为Python27

idle.bat is Windows specific, and there are Windows-specific reasons for its existence. idle.bat是 Windows 特定的,它的存在有特定于 Windows 的原因。 The generic way to start IDLE in its default startup mode (partly user customizable) is somepython -m idlelib where somepython refers to and start a python binary.以默认启动模式(部分用户可自定义)启动 IDLE 的通用方法是somepython -m idlelib其中somepython引用并启动 python 二进制文件。 It can be python , pythonw (Windows), python3 (*nix), or py -3.y (Windows).它可以是pythonpythonw (Windows)、 python3 (*nix) 或py -3.y (Windows)。 For 2.x, use idlelib.idle instead of idlelib .对于 2.x,使用idlelib.idle而不是idlelib

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM