From PyMOLWiki
Revision as of 20:41, 6 December 2011 by Tlinnet (talk | contribs) (External modules - numeric)
Jump to: navigation, search


In November 2011, a group of PyMOL users initiated together with Jason Vertrees, a project to let PyMOL scripts be under version control system (VCS) called Git.

We hope that script authors and PyMOL users would be interested in this option.


The benefits from this project, is

  1. A convenient way, to let PyMOL users download all scripts at the PyMOL wiki, with a minimum of effort.
  2. The possibility to let script authors push changes to their script out to PyMOL users.
  3. Easier requiring assistance from the PyMOL mailing list.
  4. Script will be tested for malicious code before added to the official repository.

Read here to install:

Official repository

The official repository is located at:

And the Git Read-Only access is:


Same namespace

As a part of this project, we recommend that the name for script filename and pagename at the PyMOL wiki are the same. All letters should also be small for both.
This will ease the use of the script

Example: colorbydisplacement

Example of namespace

For a description of use

For a color coded view

See the raw code or download manually, by right clicking the following link here -> Save as:

In the users local script library


To import in PyMOL

import colorbydisplacement

To print the available functions in PyMOL


This means, that if a PyMOL user look in their local repo directory, and wonder what does. Then user can write:

Here a description of the of script is presented, with example of use and images. When the user then wants to use the script, one can simply write: import colorbydisplacement

To find out the defined functions, one can then either look at the wiki page, OR write in PyMOL. help(colorbydisplacement) which automatically returns the functions.

Read more here

  1. Simple install instructions for all PyMOL users.
  2. Information how to contribute scripts to the repository. It's easy!
  3. Guidelines how to make a good PyMOL wiki script page.
  4. Information how Repository admins handle the contributions

Know problems

The slash "\" and "/" problem

Windows uses backslash \, and Linux uses forwardslash / in folder and path definitions.
This give sometimes problems, when joining paths in script and plugins, if the author has not foreseen this.
We hope windows users can help report this suggest a solution, so scripts can be used on both systems.

It could get solved, by implementing something like this

import sys,os,platform
print sys.path
for path in sys.path:
    if platform.system() == 'Windows':
        path_desc = "\\"
    if platform.system() == 'Linux':
        path_desc = "/"
print sys.path

def add_to_path():
    for path in sys.path:
        if 'Pymol-script-repo' in path:
            if platform.system() == 'Windows':
                modules_path = path + "\\modules"
                path_desc = "\\"
            if platform.system() == 'Linux':
                modules_path = path + "/modules"
                path_desc = "/"

print "\n", add_to_path()

External modules - numeric

Numeric is sometimes used in scripts. This module is easy to install in Linux, but not so easy to make part of a PyMOL installation.

One could put in some "try" statements, to solve the problem.

import os,sys
    import mechanize
except ImportError:
    print("Could not import mechanize, trying again")
        import modules.mechanize
        print("I succeded importing mechanize")
        print("I am sorry, no mechanize for you today")