2

I want to run the exe file with command line arguments in Mac terminal

p1.exe -f input.txt

But im getting error -bash: p1: command not found

I have converted python file p1.py into p1.exe using

pyintsaller p1.py --onefile

And running the python file with arguments works

python p1.py -f input.txt
3
  • If that .exe is a Windows PE executable, it won't execute on macOS. No Windows executable will (unless you're using an emulation or virtualization layer). You'll need to package into a macOS .app package or build a macOS installer instead. Commented Mar 19, 2019 at 9:50
  • its a linux executable Commented Mar 19, 2019 at 9:59
  • What do you mean by "Linux executable"? Do you mean an ELF file? I don't think macOS can execute an ELF executable natively either. The native executable file format for modern macOS systems is Mach-O. Commented Mar 19, 2019 at 10:13

2 Answers 2

1

This isn't to do with Python, but is a basic command shell issue. To run an executable from the current directory, you need to use the ./ prefix.

./p1.exe -f input.txt

Note, it's a bit odd to use a .exe extension for a Linux executable.

Sign up to request clarification or add additional context in comments.

Comments

0

Note that on Unix like systems (Linux/Unix/Solaris/MacOS). scripts can be run without explicitly invoking interpreter, if two conditions are meet:

  • script file starts with this line (or similar): #!/usr/bin/env python

  • file has executable attribute flag is set

Then you can run script like this:

./p1.py --onefile

./ means run thing from local directory. If this is not pressent the it tries to run things located by PATH variable, that is why you can run interpreter python

1 Comment

My question was how to run exe file

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.