python - 是否可以将构建的 pyinstaller 可执行文件导入 python 脚本?
问题描述
是否可以在 python 脚本中导入构建的 pyinstaller 包?
例如,我在以下脚本上运行了 pyinstaller:
count_to_ten.py
def count():
for i in range(10):
print(i)
然后,我将其与 pyinstaller 打包,pyinstaller -F count_to_ten.py
用于生成可执行文件count_to_ten.exe
我知道我可以count_to_ten.py
使用导入import count_to_ten
,然后count()
根据需要调用。
exec
除了使用or执行此操作之外,是否有任何等效的方法可以使用“内置”pyinstaller 文件执行此操作subprocess
?
理想情况下相当于:
main.py
import count_to_ten.exe
count_to_ten.count()
编辑 建议解决方案“在使用 PyInstaller 创建的单文件 exe 中导入外部模块”解决了这个问题。建议的解决方案解决了相反的问题。
上述解决方案涉及将外部.py
文件导入 pyinstaller 创建的单文件 exe。我想在不使用or的情况下将单文件 exe 文件导入解释.py
脚本。exec
subprocess
解决方案
推荐阅读
- python - 为什么 python Queue 类没有定义 __repr__ 或 __str__ ?
- php - Laravel Passport:错误的令牌 JSON 响应
- r - 当我尝试在 RStudio 中的 Windows 10 上创建共享库文件时找不到“make”
- scala - 如何使用 Scala 创建顶点路由器
- c - 将函数从 C 移植到 OPENCL
- mongodb - 从 Scala 中的 Mongo DB 收集文档字段到数组
- javascript - o1.constructor = subType 的目的是什么?
- graphql - GraphQL 服务器 - 如何在字段解析器中传递多个级别的根
- r - R Shiny 使用反应值激活操作按钮两次
- java - 当数组中有很多重复时优化快速排序