2024-03-28 15:57:01 发布
网友
我试图用pyinstaller将一个c文件转换成可执行文件。现在我想用pyinstaller编译的原因是,exe文件应该同时在mac和windows机器上运行。在
现在,怎么能做到呢?在
可以在Pyinstaller可执行文件中包含Cython/C模块。在
但是,Pyinstaller不适合您的目标,即生成一个在Mac和Windows上运行的可执行文件。From the first question of the Pyinstaller FAQs:
Can I use PyInstaller as a cross-compiler? Can I package Windows binaries while running under OS X?No, this is not supported. [...]
Can I use PyInstaller as a cross-compiler? Can I package Windows binaries while running under OS X?
No, this is not supported. [...]
似乎您根本误解了Pyinstaller的作用:它将Python脚本与Python及其库打包在一起,这样您就可以使用Python脚本,而不必单独安装Python。要做到这一点,尽管它需要打包一个特定于平台的Python版本,因此可执行文件只能在创建它的同一操作系统上工作。在
此外,它还处理zipping them up and the extracting them into a temporary folder when run编译的库(如Cython模块)。因此,即使Pyinstaller设法将Python的两个版本绑定在Windows和Mac上,但C编译的模块仍然只能在一个平台上编译,所以这样做实际上降低了代码的可移植性。在
我不相信有什么明显的工具可以满足你的要求。在
可以在Pyinstaller可执行文件中包含Cython/C模块。在
但是,Pyinstaller不适合您的目标,即生成一个在Mac和Windows上运行的可执行文件。From the first question of the Pyinstaller FAQs:
似乎您根本误解了Pyinstaller的作用:它将Python脚本与Python及其库打包在一起,这样您就可以使用Python脚本,而不必单独安装Python。要做到这一点,尽管它需要打包一个特定于平台的Python版本,因此可执行文件只能在创建它的同一操作系统上工作。在
此外,它还处理zipping them up and the extracting them into a temporary folder when run编译的库(如Cython模块)。因此,即使Pyinstaller设法将Python的两个版本绑定在Windows和Mac上,但C编译的模块仍然只能在一个平台上编译,所以这样做实际上降低了代码的可移植性。在
我不相信有什么明显的工具可以满足你的要求。在
相关问题 更多 >
编程相关推荐