Question: ImportError: No module named pymol (Windows)
0
gravatar for po9.don
21 months ago by
po9.don0
po9.don0 wrote:

Hi. I found this script online:

"""
Pymol python script to add a function to color atoms by residues.
syntaxe in Pymol :
color_by_resname selection
"""

__author__      = "Thibault Tubiana"
__copyright__   = "Copyleft"

color_code = {
  'ALA' : 'lemon', 
  'CYS' : 'yellow', 
  'ASP' : 'red', 
  'GLU' : 'violet2', 
  'PHE' : 'emerald', 
  'GLY' : 'orange', 
  'HIS' : 'peacock', 
  'ILE' : 'lime2', 
  'LYS' : 'indigo', 
  'LEU' : 'grass', 
  'MET' : 'green', 
  'ASN' : 'purple2', 
  'PRO' : 'tangerine', 
  'GLN' : 'magenta2', 
  'ARG' : 'blue', 
  'SER' : 'scarlet', 
  'THR' : 'vermillion', 
  'VAL' : 'lemon-lime', 
  'TRP' : 'cyan', 
  'TYR' : 'turquoise',
}

def create_color():
    """
    Create missing color in pymol
    """
    cmd.set_color("scarlet",[1.0,0.2,0.0])
    cmd.set_color("vermillion",[1.0,0.4,0.0])
    cmd.set_color("tangerine",[1.0,0.8,0.0])
    cmd.set_color("lemon",[0.8,1.0,0.0])
    cmd.set_color("lemon-lime",[0.6,1.0,0.0])
    cmd.set_color("lime2",[0.4,1.0,0.0])
    cmd.set_color("grass",[0.2,1.0,0.0])
    cmd.set_color("emerald",[0.0,1.0,0.4])
    cmd.set_color("turquoise",[0.0,1.0,0.8])
    cmd.set_color("peacock",[0.0,0.4,1.0])
    cmd.set_color("indigo",[0.4,0.0,1.0])
    cmd.set_color("purple2",[0.8,0.0,1.0])
    cmd.set_color("magenta2",[1.0,0.0,0.8])
    cmd.set_color("violet2",[1.0,0.0,0.4])



def color_by_resname(selection="all"):
    """
    this function aims to color residues. The color of each residues is from
    this article : 
    Taylor, W. R. (1997). Residual colours: a proposal for aminochromography.
    Protein Engineering, 10(7), 743-6.
    usage on pymol : 
    color_by_resname selection.
    > eg: color by resname on chain A.
      color_by_resname chain A
    > eg: color by resname on chain A and only on ALA and LYS.
      color_by_resname chain A and resname ALA+LYS
    > eg: color all by resname
      color_by_resname all
    """
    create_color()
    for res in color_code:
        sel = selection + " and resname %s" % res
        cmd.color(color_code[res], sel)

cmd.extend("color_by_resname",color_by_resname)

and I am trying to add to it. I want to make my script fetch the proteins instead of me having to use the fetch command in the PyMOL console. How can I import PyMOL propertly into Python so I can use the fetch command. Every time I try to import it, I get this error : ImportError: No module named pymol. I am a beginner with Python and I do not really know how to change any paths, so a simple explanation to this problem would be very helpful!

Thanks in advance!

ADD COMMENTlink modified 21 months ago by WouterDeCoster40k • written 21 months ago by po9.don0
0
gravatar for WouterDeCoster
21 months ago by
Belgium
WouterDeCoster40k wrote:

You first need to install the module, see for example this page: http://www.pymol.org/install

ADD COMMENTlink written 21 months ago by WouterDeCoster40k

I already downloaded PyMOL from the website and have the PyMOL Console and GUI on my computer. Do I need to reinstall them?

ADD REPLYlink written 21 months ago by po9.don0

I don't work on Windows, but do you have multiple versions of Python installed perhaps?

ADD REPLYlink written 21 months ago by WouterDeCoster40k

Nope. I just tried pymol.cmd.fetch and it works. Thanks though!

ADD REPLYlink written 21 months ago by po9.don0
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1103 users visited in the last hour