是否可以将内置的pyinstaller可执行文件导入python脚本?

时间:2020-10-21 20:35:03

标签: python python-import pyinstaller

是否可以在python脚本中导入内置的pyinstaller软件包?

例如,我已在以下脚本上运行pyinstaller:

count_to_ten.py

def count():
   for i in range(10):
      print(i)

然后我使用pyinstaller -F count_to_ten.py将其与pyinstaller打包以生成可执行文件count_to_ten.exe

我知道我可以使用count_to_ten.py导入import count_to_ten,然后根据需要调用count()

除了使用execsubprocess执行此操作以外,还有其他等效方法可以使用“内置”的pyinstaller文件执行此操作吗?

理想情况下等于:

main.py

import count_to_ten.exe

count_to_ten.count()

修改 建议解决方案“ Importing external module in single-file exe created with PyInstaller”解决此问题。建议的解决方案可以解决相反的问题。

上述解决方案涉及将外部.py文件导入到pyinstaller创建的单个文件exe中。我想不使用.pyexec将单文件exe文件导入解释的subprocess脚本中。

0 个答案:

没有答案