简体   繁体   English

如何在Ubuntu,Windows和MAC上运行Python脚本

[英]How to run Python script on Ubuntu, Windows and MAC

I'm making Python software using wx GUI library but was wondering how to run this script on different OS's. 我正在使用wx GUI库制作Python软件,但想知道如何在不同的OS上运行此脚本。 For example, do I need to create executable installation file or bat file on Windows and sh file in Ubuntu? 例如,是否需要在Windows上创建可执行安装文件或bat文件,在Ubuntu中创建sh文件?

I've got #!/usr/bin/env python at the top of the file and I can seem to run it by actually double clicking it and clicking it on "RUN" on prompt window but I would like it to be more professional as the users are not programmers. 我在文件顶部有#!/usr/bin/env python ,我似乎可以通过实际双击它并在提示窗口上的“ RUN”上单击它来运行它,但我希望它更加专业因为用户不是程序员。

Being used to run python scripts on both linux and Windows environments, I know that you can use the same script for both environments. 我知道在Linux和Windows环境下都可以运行python脚本,因此您可以在两种环境下使用相同的脚本。 Keep using your shebang in Linux, it won't be procesed in windows (as it is actually a comment :). 在Linux中继续使​​用您的shebang,它将不会在Windows中处理(因为它实际上是一个注释:)。

Once Python is installed in Windows, you can actually simply double click on the script (it will run by default in a cmd window), run it using the cmd or launch it in idle. 在Windows中安装Python之后,您实际上可以简单地双击脚本(默认情况下,它将在cmd窗口中运行),使用cmd运行该脚本或以空闲状态启动它。

If you want to develop python scripts on windows however, you'll need some more tools :). 但是,如果要在Windows上开发python脚本,则需要更多工具:)。

If you want to be more professional (and prevent your users to modify the code :), you can still think about creating an exe file : http://www.lyxia.org/blog/developpement/python/creez-des-executables-46 (warning, french inside), by using pyinstaller http://www.pyinstaller.org/ . 如果您想变得更加专业(并防止用户修改代码:),仍然可以考虑创建exe文件: http : //www.lyxia.org/blog/developpement/python/creez-des-executables -46 (警告,内部法语),使用pyinstaller http://www.pyinstaller.org/ Works for windows and linux 适用于Windows和Linux

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM