在bashor 中sh,我想任何以 开头的#都是注释。
但是在bash脚本中我们写:
#!/bin/bash
Run Code Online (Sandbox Code Playgroud)
在 Python 脚本中,有:
#!/bin/python
Run Code Online (Sandbox Code Playgroud)
这是否意味着它#本身是一个评论而#!不是?
在脚本中,第一行应该指定解释器的路径。
但是在 Linux、Unix 或 BSD 的不同服务器上,此路径可能不同。
什么更可取?
#!/usr/bin/env bash
Run Code Online (Sandbox Code Playgroud)
或者
#!/bin/bash
Run Code Online (Sandbox Code Playgroud) #!/usr/bin/env <sh|bash|python>与#!/bin/bash,#!/bin/sh或相比,使用shebang的目的是什么#!/usr/bin/python?
我使用以下命令来检查此答案给出的 python 版本。除了一个错误外,它确实有效,如下所示。任何人都可以解释为什么?
$ sudo find / -type f -executable -iname 'python*' -exec file -i '{}' \; \
| awk -F: '/x-executable; charset=binary/ {print $1}' \
| xargs readlink -f | sort -u | xargs -I % sh -c 'echo -n "%: "; % -V'
Run Code Online (Sandbox Code Playgroud)
错误:
find: ‘/run/user/1000/gvfs’: Permission denied
Run Code Online (Sandbox Code Playgroud) 我在我的系统 14.04 LTS 中使用 Netbeans IDE 8.0。
我已经按照此链接在 Netbeans 8.0 中安装了 Python 插件。
我也python-3.4.1.tgz从这个链接下载并在终端中安装如下,
tar -xvf Python-3.4.1.tgz
cd Python-3.4.1/
./configure
make
sudo make install
./python
Run Code Online (Sandbox Code Playgroud)
我终于得到了结果,
arul@arul-Aspire-5740:~/Python-3.4.1$ ./python
Python 3.4.1 (default, Sep 19 2014, 17:14:45)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
Run Code Online (Sandbox Code Playgroud)
我在终端中使用以下命令确认
python3 -V
Run Code Online (Sandbox Code Playgroud)
得到了回应,
Python 3.4.1
Run Code Online (Sandbox Code Playgroud)
但是,当我单击Auto DetectPython 平台管理器(Netbeans IDE 8.0.1)时,列表中没有 3.4.1(如下所示)。

如何解决?
更新 1
我试过,
arul@arul-Aspire-5740:~$ sudo find / -type f -executable …Run Code Online (Sandbox Code Playgroud) bash ×2
python ×2
scripts ×2
command-line ×1
environment ×1
find ×1
netbeans ×1
permissions ×1
shebang ×1