Can I generate a python executable file on my Mac that can be used on Windows

社会主义新天地 提交于 2020-01-16 06:11:07

问题


I am programming python with my Mac laptop, however, the final executable will be run on final users' Windows system. And the Windows system hasn't set up the python environment specifically.

Can I generate an executable file on my Mac laptop, and Windows user can directly run on Windows system?

I looked at py2exe, but it seems it must build the python on Windows in order to run the exe on Windows.


回答1:


You can not generate Windows executable files on OS X. You must use the platform which you want the program to run on to compile the program. If you own a copy of Windows, you could run a virtual machine on you Mac and compile it on that.




回答2:


If you are able to install a VM running Windows on your Mac, you will be able to create your Windows executable.

You can start from here: https://www.virtualbox.org/wiki/Downloads

So it is technically possible to create your Windows apps on your Mac but not on OSX.




回答3:


No. Every OS uses different compilers. You will need to create your executable for each target OS on that OS. Fortunately you can usually use the same tool on each OS though. For example, you can use cx_freeze on any OS to create the executable for that OS on which it is run.

PyInstaller also works on all 3 major platforms. As others have pointed out, technically you could own a Mac and install a virtual machine that has Windows on it and another virtual machine with your flavor of Linux that you can then create your executables on. Virtualbox is probably the best free utility out there for this.



来源:https://stackoverflow.com/questions/37292381/can-i-generate-a-python-executable-file-on-my-mac-that-can-be-used-on-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!