我在Ubuntu中运行一个python脚本,它依赖于正在安装的包。这些都是我可以调用的,但是脚本不能。在
我想这是因为脚本使用的是shell(sh)而不是bash版本
sh: genomeCoverageBed: command not found
但可以在Bash中手动调用genomecovergebed:
^{pr2}$我的Stackoverflow问题的这一部分是误导和错误的!公司名称:
I have added this shebang to the start of my python script:
#!/bin/bash
But this has not affected the outcome,
从脚本中去掉这个仍然会导致相同的错误消息 以下是脚本的一部分:
for filename in os.listdir(folder):
if filename.endswith(".sorted.bam"):
namefile = filename.replace(".sorted.bam", "_ncoverage.txt")
folder_name = filename.replace(".sorted.bam", "")
os.system("mkdir " + folder_name)
os.system("coverageBed -s -d -a bam " + folder + filename + " -b " + gff_file + " > " + folder_name + "/" + namefile)
以下是运行此脚本时发生的情况:
ubuntu@fat:~/jonathan/script$ sudo python2.7 script1.py ./Folder/ ./Folder/ref.fasta genbank.gff
sh: coverageBed: command not found
sh: genomeCoverageBed: command not found
sh: genomeCoverageBed: command not found
sh: genomeCoverageBed: command not found
sh: coverageBed: command not found
sh: genomeCoverageBed: command not found
sh: genomeCoverageBed: command not found
sh: genomeCoverageBed: command not found
sh: coverageBed: command not found
sh: genomeCoverageBed: command not found
sh: genomeCoverageBed: command not found
sh: genomeCoverageBed: command not found
sh: coverageBed: command not found
sh: genomeCoverageBed: command not found
sh: genomeCoverageBed: command not found
sh: genomeCoverageBed: command not found
sh: coverageBed: command not found
sh: genomeCoverageBed: command not found
sh: genomeCoverageBed: command not found
sh: genomeCoverageBed: command not found
sh: coverageBed: command not found
sh: genomeCoverageBed: command not found
sh: genomeCoverageBed: command not found
sh: genomeCoverageBed: command not found
sh: coverageBed: command not found
sh: genomeCoverageBed: command not found
sh: genomeCoverageBed: command not found
sh: genomeCoverageBed: command not found
sh: coverageBed: command not found
sh: genomeCoverageBed: command not found
sh: genomeCoverageBed: command not found
sh: genomeCoverageBed: command not found
sh: coverageBed: command not found
sh: genomeCoverageBed: command not found
sh: genomeCoverageBed: command not found
sh: genomeCoverageBed: command not found
你对我能做些什么有什么建议吗,或者即使我走在正确的轨道上? 谢谢你的帮助!在
正如@tdelaney在评论中提到的那样,你的shebang正在调用一个subshell。要使用python作为执行文件的程序,您需要使用如下所示的方法:
如果您将!/bin/bash,将在bash中打开。试试放#!/usr/bin/python或#!/usr/bin/env python
你用错了
当一个linux shell被要求运行一个文本文件(例如,
./myprogram.py
)时,它会查看shebang,以确定应该使用哪个程序来解释文本。在您的例子中,您要求shell运行/bin/bash
-另一个shell,它试图将python脚本解释为shell脚本。在你可以用不同的方式来写
^{pr2}$这告诉shell运行
/usr/bin/env
,它将在路径中搜索一个名为pythnon3
的东西。现在,为当前环境运行python设置。默认情况下,它是系统python,但是如果您在python虚拟环境中运行,它运行的是python。在shebang只在linuxy系统上使用,并且只在使脚本可执行并直接运行时使用。如果在windows上运行(在cygwin或其他类似unix的shell之外)或直接运行python(
python /path/to/myscript.py
),则不使用它。在相关问题 更多 >
编程相关推荐