是否可以在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()
。
除了使用exec
或subprocess
执行此操作以外,还有其他等效方法可以使用“内置”的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中。我想不使用.py
或exec
将单文件exe文件导入解释的subprocess
脚本中。