CalledProcessError:Command [inputs]返回非零退出状态1.

时间:2018-03-29 18:54:04

标签: python python-3.x python-2.7 subprocess sys

我一直在使用此代码,更具体地说,我正在实施一个演化算法link

  1. 所以这是我的问题我在代码的2个不同部分使用函数check_output但我有两个不同的输出检查出来:

    wwnnnwwwwneeennen
    b'\r\n. . . . p . . \r\n        |     \r\n. . . p-h . . \r\n      |                                                                       \r\n. . . p . . . \r\n      |       \r\np-p-h-p . . . \r\n|   *         \r\np-h-H-p-p . . \r\n        |     \r\n. . . . p . . \r\n        |     \r\n. . . . p . . \r\n        |     \r\n. . . . p-H-h \r\n              \r\nScore: 1\r\n'
    Sorting Population
    wwnnnwwwwneeennen
    Traceback (most recent call last):
    
      File "<ipython-input-39-55bfd97a1822>", line 1, in <module>
        runfile('C:/Users/kayuga/Documents/bioinformatica/projeto em                 bioinformatica fall/HI/HI/random path.py', wdir='C:/Users/kayuga/Documents/bioinformatica/projeto em bioinformatica fall/HI/HI')
    
      File "C:\Users\kayuga\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 880, in runfile
        execfile(filename, namespace)
    
      File "C:\Users\kayuga\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
        exec(compile(f.read(), filename, 'exec'), namespace)
    
      File "C:/Users/kayuga/Documents/bioinformatica/projeto em bioinformatica fall/HI/HI/random path.py", line 238, in <module>
        main()
    
      File "C:/Users/kayuga/Documents/bioinformatica/projeto em bioinformatica fall/HI/HI/random path.py", line 215, in main
        population_sorted= computePerfPopulation(population, seqs[0])
    
      File "C:/Users/kayuga/Documents/bioinformatica/projeto em bioinformatica fall/HI/HI/random path.py", line 124, in computePerfPopulation
        populationPerf[individual] = fitness(individual, sequence)
    
      File "C:/Users/kayuga/Documents/bioinformatica/projeto em bioinformatica fall/HI/HI/random path.py", line 110, in fitness
        output = subprocess.check_output("python hpview3k.py " + sequence + " " + path, shell=True)
    
      File "C:\Users\kayuga\Anaconda3\lib\subprocess.py", line 336, in check_output
          **kwargs).stdout
    
      File "C:\Users\kayuga\Anaconda3\lib\subprocess.py", line 418, in                     run
      output=stdout, stderr=stderr)
    
    CalledProcessError: Command 'python hpview3k.py wwnnnwwwwneeennen         hhppppphhppphppphp' returned non-zero exit status 1.
    
  2. 你可以看到第一个电话有效,但是第二个电话没有,我不知道为什么。

    这是我的代码:

    def fitness(sequence, path):
        output = subprocess.check_output("python hpview3k.py " + sequence + " " + path, shell=True)
        a = [int(s) for s in output.split() if s.isdigit()]
        return a[0]
    
    
    def computePerfPopulation(population, sequence):
    
        populationPerf = {}
    
        print("Sorting Population")
    
        for individual in population:
    
            print(individual)
            populationPerf[individual] = fitness(individual, sequence)
    
        return sorted(populationPerf.items(), key = operator.itemgetter(1), reverse=True)
    

    并且此块属于main:

       population = generateFirstPopulation(100, seqs[0])
    
        print(population[0])
    
        ok = subprocess.check_output("python hpview3k.py " + seqs[0] + " " + population[0], shell=True)
    
        print(ok)
        while(1):
            population_sorted= computePerfPopulation(population, seqs[0])
            print(population_sorted)
            breeders = selectFromPopulation(population_sorted, 25, 25)
            #population2 = createChildren(breeders, 2, seqs[0])
            #mutatedPop = mutatePopulation(population2, 20)
    
           # population = breeders + mutatedPop
    

    我希望有人可以帮助我 欢呼声

0 个答案:

没有答案