0

我正在尝试运行一个由 salilab 编写的 python 脚本作为建模软件的教程。本教程中有一个带有以下代码的 python 文件:

import pylab
import modeller

def r_enumerate(seq):
    """Enumerate a sequence in reverse order"""
    # Note that we don't use reversed() since Python 2.3 doesn't have it
    num = len(seq) - 1
    while num >= 0:
        yield num, seq[num]
        num -= 1

def get_profile(profile_file, seq):
    """Read `profile_file` into a Python array, and add gaps corresponding to
       the alignment sequence `seq`."""
    # Read all non-comment and non-blank lines from the file:
    f = open(profile_file)
    vals = []
    for line in f:
        if not line.startswith('#') and len(line) > 10:
            spl = line.split()
            vals.append(float(spl[-1]))
    # Insert gaps into the profile corresponding to those in seq:
    for n, res in r_enumerate(seq.residues):
        for gap in range(res.get_leading_gaps()):
            vals.insert(n, None)
    # Add a gap at position '0', so that we effectively count from 1:
    vals.insert(0, None)
    return vals

e = modeller.environ()
a = modeller.alignment(e, file='TvLDH-1bdmA.ali')

template = get_profile('1bdmA.profile', a['1bdmA'])
model = get_profile('TvLDH.profile', a['TvLDH'])

# Plot the template and model profiles in the same plot for comparison:
pylab.figure(1, figsize=(10,6))
pylab.xlabel('Alignment position')
pylab.ylabel('DOPE per-residue score')
pylab.plot(model, color='red', linewidth=2, label='Model')
pylab.plot(template, color='green', linewidth=2, label='Template')
pylab.legend()
pylab.savefig('dope_profile.png', dpi=65)

当我尝试在 cmd 中运行程序时,出现错误:没有名为 pylab 的模块,但我已经安装了 matplotlib、numpy 和 scipy,当我在 Visual Studio 中运行它时也没有问题。谁能帮我理解问题是什么?

4

1 回答 1

0

您的 python 路径可能被命令行弄乱了。您很可能安装了多个版本,并且命令行的默认版本没有安装 pylab。

请参阅...
如何在 Windows 中添加到 PYTHONPATH,以便找到我的模块/包?

于 2019-10-07T19:14:32.410 回答