如果我将 python 文件从 py 转换为 exe,那么我创建的文件导入的模块呢?

If I convert a python file from py to exe, what about the module I created that the file imports?

我创建了一个服务器和客户端文件,当我意识到我还需要将它使用的模块转换为 exe 时,我正要将它转换为 exe。我该如何处理该模块?

看起来 Auto PY to EXE uses PyInstaller 在这里做真正的工作:

A .py to .exe converter using a simple graphical interface and PyInstaller in Python.

PyInstaller will automatically bundle any dependencies it finds:

What other modules and libraries does your script need in order to run? (These are sometimes called its "dependencies".)

To find out, PyInstaller finds all the import statements in your script. It finds the imported modules and looks in them for import statements, and so on recursively, until it has a complete list of modules your script may use.

因此,只要您 import 您的依赖项位于主脚本可访问的某个位置并且您的虚拟环境处于活动状态,您应该会自动获得正确的行为。

请注意,您可能需要构建 两个 可执行文件:一个用于您的服务器,一个单独的用于您的客户端。