PyAutoGUI 到 .exe 文件
PyAutoGUI to .exe file
我正在使用一种工具将我的 python 文件转换为 .exe 文件。您可以在此视频中找到该工具 py to .exe 。
现在当我转换这段代码时,一切都很好:
width = float(input("Enter the width: "))
height = float(input("Enter the height: "))
area = width * height
print("The area is", area, "square units.")
但是每当我在其中添加一行带有 PyAutoGUI 模块的代码时,.exe 文件会立即关闭并且什么都不做。
示例:
width = float(input("Enter the width: "))
pyautogui.moveTo(492, 106, 0.2)
height = float(input("Enter the height: "))
area = width * height
print("The area is", area, "square units.")
如何防止 .exe 文件关闭以及为什么不执行 PyAutoGUI 代码?
我成功了。我做了一些事情,所以我不完全确定,但我认为在 CMD 中安装 PyAutoGUI 使其工作。
此安装程序正在使用 PYINSTALLER 创建 EXE。 PYINSTALLER 在创建 .exe 时使用默认的 python 虚拟环境。因此,如果您使用的不是默认虚拟环境(conda env 或其他 venv),那么 .exe 将无法 运行。因此,当默认环境准备好 运行 程序时,这意味着如果您在默认环境中安装所有必需的软件包并使用 pyinstaller,那么就不会有任何问题。希望我正确地解决了问题。
我正在使用一种工具将我的 python 文件转换为 .exe 文件。您可以在此视频中找到该工具 py to .exe 。
现在当我转换这段代码时,一切都很好:
width = float(input("Enter the width: "))
height = float(input("Enter the height: "))
area = width * height
print("The area is", area, "square units.")
但是每当我在其中添加一行带有 PyAutoGUI 模块的代码时,.exe 文件会立即关闭并且什么都不做。
示例:
width = float(input("Enter the width: "))
pyautogui.moveTo(492, 106, 0.2)
height = float(input("Enter the height: "))
area = width * height
print("The area is", area, "square units.")
如何防止 .exe 文件关闭以及为什么不执行 PyAutoGUI 代码?
我成功了。我做了一些事情,所以我不完全确定,但我认为在 CMD 中安装 PyAutoGUI 使其工作。
此安装程序正在使用 PYINSTALLER 创建 EXE。 PYINSTALLER 在创建 .exe 时使用默认的 python 虚拟环境。因此,如果您使用的不是默认虚拟环境(conda env 或其他 venv),那么 .exe 将无法 运行。因此,当默认环境准备好 运行 程序时,这意味着如果您在默认环境中安装所有必需的软件包并使用 pyinstaller,那么就不会有任何问题。希望我正确地解决了问题。