gpt4 book ai didi

python - 什么可以阻止工作(当 "opened with"Python 时)Python 应用程序通过双击启动?

转载 作者:行者123 更新时间:2023-11-28 16:50:04 26 4
gpt4 key购买 nike

Python 应用程序(具有由用户执行的权限)不会通过双击启动。如果我在终端中运行它(直接通过 ./theapp.pyw),我会收到“:没有这样的文件或目录”错误(虽然应用程序代码中没有这样的字符串,并且文件肯定存在(重命名并使用不同的名称结果相同))。

但如果我明确地用 Python 打开它(通过发出 python ./theapp.pyw 或右键单击并选择用 Python 2.7 打开)它工作得很好。

文件的第一行是

#!/usr/bin/env python

发出“/usr/bin/env python”命令启动 Python 2.7 控制台。

操作系统是XUbuntu Linux 11.10。唯一安装的 Python 是 Ubuntu 的默认 2.7。

有什么想法吗?

最佳答案

pyw 文件适用于 windows http://filext.com/file-extension/PYW

而在 Windows 中,shebang 行被忽略了。只需使用 .py 脚本即可。

您还可以尝试创建一个 bash 脚本来启动带有您想要的特定标志的 python 脚本。

关于python - 什么可以阻止工作(当 "opened with"Python 时)Python 应用程序通过双击启动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8548148/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com