我需要一个.command文件,该文件可以在与其相同的目录中启动python脚本。
到目前为止,我得到了这样的结论:
#!bin/bash
python /Users/username/Desktop/IF.py但是每次终端都会返回相同的错误。
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]请注意,错误发生在我的两行代码中的第三行...
发布于 2015-10-11 14:00:12
为什么不从一开始就启动python脚本本身呢?您可以像这样在顶部添加shebang:
#! /user/bin/env python
... the rest of your python script here然后只需给该脚本可执行的权限:
chmod +x nameofscript.py然后像这样启动它:
./nameofscript.py如果你不想让脚本依赖于环境,只需使用下面的shebang:
#! /usr/bin/python发布于 2015-10-11 14:07:16
也许是因为shebang (或者hashbang)。关于what is (wiki)。
#!bin/bash
^
python /Users/username/Desktop/IF.py这意味着系统将使用bin/bash来运行此程序,但bin/bash表示path/bin/bash。
例如,如果您在/home中,则系统将使用/home/bin/bash来运行此程序。
我认为你需要这个:
#!/bin/bash
python /Users/username/Desktop/IF.py请注意,我将#!bin/bash替换为#!/bin/bash。
https://stackoverflow.com/questions/33062039
复制相似问题