如何安装Python模块“color_gradient”

时间:2015-02-27 12:33:09

标签: python python-2.7 module

我正在扩展一个基于网络的生物信息学工具,该工具用HTML,Javascript和Python编写。在运行应用程序时,其中一个脚本会出错:

[Fri Feb 27 13:22:27.528636 2015] [cgi:error] [pid 1267] [client 127.0.0.1:45930] AH01215: Traceback (most recent call last):, referer: http://localhost/circular/index.html
[Fri Feb 27 13:22:27.528757 2015] [cgi:error] [pid 1267] [client 127.0.0.1:45930] AH01215:   File "/var/www/localhost/cgi-bin/circular_handler_beta_v2.py", line 10, in <module>, referer: http://localhost/circular/index.html
[Fri Feb 27 13:22:27.528787 2015] [cgi:error] [pid 1267] [client 127.0.0.1:45930] AH01215:     import color_gradient, referer: http://localhost/circular/index.html
[Fri Feb 27 13:22:27.528828 2015] [cgi:error] [pid 1267] [client 127.0.0.1:45930] AH01215: ImportError: No module named color_gradient, referer: http://localhost/circular/index.html
[Fri Feb 27 13:22:27.538274 2015] [cgi:error] [pid 1267] [client 127.0.0.1:45930] End of script output before headers: circular_handler_beta_v2.py, referer: http://localhost/circular/index.html

问题在于模块,调用&#34; color_gradient&#34;无法导入。我试图在Google上搜索和安装此模块,但我没有得到满意和明确的答案。

有人知道在哪里找到并安装这个模块吗?

完整的脚本是为了共享,但这里是使用模块的函数:

def get_genes(nc_code,strand,color):
cursor1 = conn.cursor()
if (strand == "+" or strand == "-"):
    # print ("SELECT start,stop,strand,locus_tag,ncbi_gi,cog,synonym,product FROM gene WHERE nc_accession = " + '"' + nc_code + '"' + " AND strand = " + '"' + strand + '"' + ";")
    cursor1.execute("SELECT start,stop,strand,locus_tag,ncbi_gi,cog,synonym,product FROM gene WHERE nc_accession = " + '"' + nc_code + '"' + " AND strand = " + '"' + strand + '"' + ";")
else:
    # print("SELECT start,stop,strand,locus_tag,ncbi_gi,cog,synonym,product FROM gene WHERE nc_accession = " + '"' + nc_code + '"' + ";")
    cursor1.execute("SELECT start,stop,strand,locus_tag,ncbi_gi,cog,synonym,product FROM gene WHERE nc_accession = " + '"' + nc_code + '"' + ";")
data = cursor1.fetchall()
# print  data
context_genes = []
for row in data:
    start,stop,strand,locus_tag,gi_code,cog,synonym,product = row   
    # print row
    add_data = ""
    cog_categories = []
    gene_color = color
    if color == "cog":
            gene_color,cog_categories = get_cog_color(cog)
    if color == "scl":
        scl,gene_color = get_scl(nc_code,gi_code)
        if gene_color == None:
            #Like unknown, but lighter grey
            gene_color = "#a9a7aa"
        if color== "Custom":
            if str(gi_code) in imported_custom_colors.keys():
                gene_color = imported_custom_colors[str(gi_code)]
            else:
                gene_color = "white"
    if feature == "gc_p":
        gcp, gcp_color = get_gene_statistical_data(nc_code,gi_code,feature)
        add_data = gcp
        if color == "scale_red_green":
            gene_color = gcp_color
        if feature == "gc_skew":
                gc_skew, gc_skew_color = get_gene_statistical_data(nc_code,gi_code,feature)
                add_data = gc_skew
                if color == "scale_red_green":
                        gene_color = gc_skew_color
        if feature == "at_skew":
                at_skew, at_skew_color = get_gene_statistical_data(nc_code,gi_code,feature)
                add_data = at_skew
        if color == "scale_red_green":
                gene_color = at_skew_color
    if feature == "numeric_data":
        try:
            add_data = float(numeric_data_data[str(gi_code)][0])
            gene_color = numeric_data_data[str(gi_code)][1]
        except:
            add_data = 0
            gene_color = "white"
    context_genes.append([start,stop,strand,locus_tag,gi_code,gene_color,synonym,product,cog_categories,add_data])
# print context_genes # empty
return context_genes

我理解的是规则:

if str(gi_code) in imported_custom_colors.keys():
            gene_color = imported_custom_colors[str(gi_code)]

正在使用该模块。

1 个答案:

答案 0 :(得分:0)

我向提出申请的人提出了同样的问题,他自己开发了模块,然后我得到了模块。