简体   繁体   中英

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. For example, do I need to create executable installation file or bat file on Windows and sh file in Ubuntu?

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.

Being used to run python scripts on both linux and Windows environments, I know that you can use the same script for both environments. Keep using your shebang in Linux, it won't be procesed in windows (as it is actually a comment :).

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.

If you want to develop python scripts on windows however, you'll need some more tools :).

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/ . Works for windows and linux

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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