I need a .command
file that can launch a python script in the same directory as it.
I have so far gotten this:
#!bin/bash
python /Users/username/Desktop/IF.py
But every time the Terminal returns the same error.
Last login: Sun Oct 11 01:48:38 on ttys000
MacBook-Pro:~ username$ /var/folders/m7/yf7p3vdj2mx0l9r7qb68rttc0000gn/T/Cleanup\ At\ Startup/run 466235498.368.command.command ; exit;
/var/folders/m7/yf7p3vdj2mx0l9r7qb68rttc0000gn/T/Cleanup At Startup/run-466235498.368.command.command: line 3: bin/bash: No such file or directory
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.
[Process completed]
Please note the error is on line 3 of the 2 lines of code I have...
Why not just launch the python script itself from the get-go? You can add a shebang at the top like so:
#! /user/bin/env python
... the rest of your python script here
Then just give the script executable permissions:
chmod +x nameofscript.py
Then just launch it like so:
./nameofscript.py
In case you don't want the script to rely on the environment, just use the following shebang instead:
#! /usr/bin/python
Maybe because the shebang (or hashbang ). About what is shebang (wiki) .
#!bin/bash
^
python /Users/username/Desktop/IF.py
This means the system will use bin/bash
to run this program, but bin/bash
means path/bin/bash
.
For example, if you're in /home
then the system will use /home/bin/bash
to run this program.
I think you need this:
#!/bin/bash
python /Users/username/Desktop/IF.py
Note that I replaced #!bin/bash
to #!/bin/bash
.
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.