Home > database >  Command line scripts in python package: Do they work on windows machines or only on Linux?
Command line scripts in python package: Do they work on windows machines or only on Linux?

Time:10-26

I'm experimenting with command line scripts on a windows machine as explained enter image description here

Are command line scripts in python packages strictly a Linux thing? How can I get this to work on windows?

CodePudding user response:

This is likely not the answer you're going to like: Windows works by associating file extensions to execution methods. The problem is: funniest-joke has no file extension, so Windows doesn't know what execution method it should invoke to execute the file. So, it asks you. (What you want to do: write a PowerShell or CMD wrapper script that invokes python directly.)

Linux looks at the first line of the file (or first n bytes, e.g. 512 to 4096 bytes) to determine an execution method. Scripts have a shebang, "#!". Native machine executables have a different signature. If you really want to get into the details, look at the source code for the exec system call, or look at the file command's manual page.

  • Related