简体   繁体   English

无法通过双击打开 python 脚本

[英]cannot open python script by double clicking

i have searched on multiple forums and looks like others met similar issues but I haven't read a straightforward explanation yet.我在多个论坛上搜索过,看起来其他人也遇到了类似的问题,但我还没有读到直接的解释。 what I am trying to do is to simply open my python script by double clicking it.我想要做的是通过双击打开我的 python 脚本。 it used to work, but not anymore.它曾经有效,但不再有效。 my python scripts can still be opened via idle.我的python脚本仍然可以通过空闲打开。 and executable when it is opened and F5 pressed.并且在打开并按下 F5 时可执行。

if on windows or linux, right click, open with ... select python executable, or Idle.如果在 Windows 或 linux 上,右键单击,打开方式...选择 python 可执行文件或空闲。 whichever you want the default action to be.无论您希望默认操作是什么。 then select the option to "always use this to open .py files"然后选择“始终使用它打开 .py 文件”选项

If on a Mac, you can CTRL+Click the file, Get info > Open With and change it to Python Launcher.如果在 Mac 上,您可以 CTRL+单击文件,获取信息 > 打开方式并将其更改为 Python Launcher。 Click Change All.单击全部更改。 Double clicking should run the script.双击应该运行脚本。

Another way is to use pyinstaller which makes the script into an executable.另一种方法是使用 pyinstaller 将脚本变成可执行文件。 It is pretty straightforward to use.使用起来非常简单。

Change the "open with..." preference for the py files by shift + right click and choose open with from the menu.通过 shift + 右键单击​​更改 py 文件的“打开方式...”首选项,然后从菜单中选择打开方式。 Make sure you tick the use always option确保勾选始终使用选项

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

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