Common PyMOL Mistakes and How to Fix Them: Troubleshooting Guide

Common PyMOL Mistakes and How to Fix Them: Troubleshooting Guide

Most PyMOL problems have simple causes and two-line fixes — but only if you know where to look. These are the ten issues that appear most often in PyMOL help threads, lab Slack channels, and frustrated emails to supervisors at 11pm before a paper deadline.

01
Very common — MD trajectories
Structure looks fragmented, exploding, or split across the box after loading a trajectory

You load an MD trajectory and the protein looks shattered — chains and atoms scattered across the box, disconnected, nowhere near each other. This is not a PyMOL bug. It’s periodic boundary condition (PBC) artifacts in the raw trajectory: atoms that crossed the simulation box boundary during MD appear on opposite sides of the box in the coordinates.

The fix — preprocess before loading
Never visualize a raw GROMACS or AMBER trajectory. Run PBC correction first in terminal before opening PyMOL:

gmx trjconv -s md.tpr -f md.xtc -o md_whole.xtc -pbc whole
gmx trjconv -s md.tpr -f md_whole.xtc -o md_vis.xtc -center -pbc mol -ur compact

For AMBER, run autoimage then center in cpptraj. Then load the processed trajectory into PyMOL.
02
Pre-submission disaster
White background turns gray, black, or transparent in the exported PNG

You set bg_color white, ray trace, export a PNG — and the background renders as black, gray, or the checkered transparency pattern when dropped into PowerPoint or Word. The cause is almost always ray_opaque_background being set to 0 (off), which makes PyMOL render a transparent background regardless of what color you set.

The fix — two commands, every time
Run both of these before every figure export — not just bg_color white:

bg_color white
set ray_opaque_background, 1

Put both lines in every figure script. The bg_color sets what you see interactively; ray_opaque_background controls what gets rendered into the exported file. You need both.
03
Performance
Ray tracing is extremely slow or crashes PyMOL

Ray tracing a complex scene with surfaces, many objects, and large proteins can take 20–40 minutes or crash with an out-of-memory error. Three culprits cause almost all ray trace slowdowns: high surface quality settings, a very large pixel count, and too many loaded objects in the session.

The fix — optimize before rendering
Delete objects you don’t need in the final figure: delete unused_object. Lower surface quality while working interactively and raise it only for the final export: set surface_quality, 0 (interactive) vs set surface_quality, 2 (export). Render at the minimum pixel count that meets your journal’s DPI requirement — a single-column figure rarely needs more than ray 1200, 900. If PyMOL still crashes, try the open-source version compiled without memory limits, or render headless with pymol -c script.pml where there is no GUI overhead.
04
Coloring
Surface shows wrong color — ignores color commands or stays gray

You color the protein blue, then show the surface — and the surface is gray. Or you color the surface red, and it shows as the atom color instead. Surfaces in PyMOL can be colored independently of the underlying cartoon/sticks representation, and they have their own color state that can override atom-based coloring.

The fix — use set surface_color or recolor after show surface
Color commands applied before show surface may not propagate to the surface. Apply colors after adding the surface representation, or explicitly target the surface:

show surface
color slate, chain A ← apply after show surface

To force a specific surface color regardless of atom colors:
set surface_color, white ← overrides everything with white

To reset surface color back to following atom colors:
set surface_color, default
05
Selections
Selections return zero atoms or select the wrong residues

You run select site, resi 100 and chain A and get zero atoms selected, or the selection highlights something completely wrong. Three causes account for most broken selections: wrong residue numbering (the PDB uses author numbering which may differ from sequence numbering), wrong chain ID case (chain A ≠ chain a), or the residue being a HETATM not covered by standard selection keywords.

The fix — inspect before selecting
Before selecting specific residues, run iterate all, print(chain, resi, resn) (or just the first 50: iterate first 50, print(chain, resi, resn)) to see the actual chain IDs and residue numbers as PyMOL sees them. Chain IDs are case-sensitive. For heteroatoms like ligands, use hetatm or resn LIG rather than resi. If residue numbers look right but atoms aren’t selected, check for insertion codes: residue “100A” uses resi 100A syntax.
06
AlphaFold — very common
AlphaFold pLDDT coloring looks flat, compressed, or entirely one color

You run spectrum b, blue_red on an AlphaFold structure and the whole protein appears nearly the same color — no visible gradient. The cause is almost always the missing minimum and maximum arguments. Without them, PyMOL scales the gradient to the actual min and max B-factor values in the file, which compresses the useful confidence range into an invisible gradient.

The fix — always set minimum and maximum
spectrum b, blue_cyan_yellow_orange_red, minimum=50, maximum=100

The minimum=50 clamps the lower end so everything below 50 gets the same “lowest” color, and the gradient covers the meaningful 50–100 range. Without these arguments, a protein where pLDDT ranges from 48 to 97 shows an almost invisible gradient because PyMOL spreads the full color scale across only a 49-unit range. Always specify both arguments for AlphaFold structures.
07
Sessions
Session file not saving, or loaded session looks different from what was saved

The most common session save failure: the .pse file saves without error, but when you load it the next day the structure looks different — wrong orientation, missing colors, different representations. This almost always happens because PyMOL saves the state of all objects in the session, but if you’ve loaded large external files (trajectories, maps) they may not embed correctly in all versions.

The fix — save both .pse and .pml
PSE files embed everything but can occasionally have compatibility issues between PyMOL versions. Supplement every PSE with a PML script saved via log_close or manually:

save session.pse ← for quick restoration
save session.pml ← text record of all commands for robustness

Also, if you are using trajectories, the trajectory file is referenced by path — not embedded. If you move the XTC file, the PSE can’t reload it. Keep PSE and trajectory files in the same directory and use relative paths.
08
Measurements
H-bond distances not appearing or showing too few bonds

You run distance hbonds, LIG, pocket, mode=2 and nothing appears — or only one or two bonds show when you know there are more. PyMOL’s H-bond detection uses a geometric criterion based on donor-acceptor distance and angle, but it also requires hydrogen atoms to be present in certain configurations. Many PDB files don’t include hydrogens, causing H-bond detection to miss bonds.

The fix — try mode=0 and add hydrogens
First try the simple contact distance to confirm atoms are close enough:
distance contacts, LIG, pocket, 3.5

If contacts appear but mode=2 doesn’t, the issue is likely missing hydrogens. Add them: h_add (adds hydrogens computationally). Then retry distance hbonds, LIG, pocket, mode=2. For more accurate H-bond detection, use PLIP (plip-tool.org) which handles missing hydrogens properly.
09
Figure quality
Cartoon helices look flat and ribbon-like instead of rounded

Your figures show flat ribbon helices instead of the smooth, rounded tube-style helices seen in most publications. This is a setting that’s off by default — PyMOL uses a simpler flat helix representation unless you enable fancy helices explicitly.

The fix — one setting, always enable it
set cartoon_fancy_helices, 1

Add this to every figure script. While you’re at it, enable smooth loops too:
set cartoon_smooth_loops, 1

If you want these settings every time PyMOL opens, add both lines to your PyMOL config file (~/.pymolrc on Mac/Linux or pymolrc.pml in the PyMOL installation directory on Windows). Anything in that file runs automatically at startup.
10
Installation / launch
PyMOL opens but the viewer window is black, blank, or flickering

The GUI opens but the 3D viewer is black or blank — or structures load but don’t render visually. The cause is almost always an OpenGL or graphics driver problem: PyMOL’s 3D viewer requires hardware-accelerated OpenGL and can fail when drivers are outdated, when running over a remote connection, or when there’s a conflict with virtual display environments.

The fix — depends on your platform
On Linux: Update your GPU drivers. Try pymol -M to disable hardware acceleration (software rendering — slower but works anywhere).

Remote/SSH: PyMOL’s viewer can’t render over SSH without X11 forwarding. Either forward X11 (ssh -X) or run PyMOL headless (pymol -c script.pml) to generate figures without a display.

On macOS Apple Silicon: Use the conda-forge build — conda install -c conda-forge pymol-open-source. The arm64 native build resolves most display issues on M-series Macs.

On Windows: Update your graphics drivers from the GPU manufacturer (NVIDIA, AMD, or Intel), not from Windows Update.

Quick troubleshooting reference

SymptomMost likely causeFix
Fragmented / exploding structureRaw MD trajectory with PBC artifactsgmx trjconv -pbc whole then -center
Gray or black PNG exportray_opaque_background = 0set ray_opaque_background, 1
Very slow ray traceHigh surface quality or too many objectsReduce surface_quality, delete unused objects
Surface wrong colorColor applied before show surfaceColor after show surface, or set surface_color
Selection zero atomsWrong chain ID, residue number, or HETATMiterate all, print(chain, resi, resn) to inspect
pLDDT coloring flatMissing minimum/maximum argumentsspectrum b, …, minimum=50, maximum=100
Session loads differentlyPSE version mismatch or missing trajectorySave PML script alongside PSE
H-bonds not showingMissing hydrogens in PDB fileh_add then retry distance mode=2
Flat ribbon helicescartoon_fancy_helices = 0set cartoon_fancy_helices, 1
Black viewer windowOpenGL / driver issuepymol -M or update GPU drivers
The .pymolrc file — fix problems permanently
Many of these issues are caused by poor default settings. Add your preferred defaults to the PyMOL startup file (~/.pymolrc on Mac/Linux) so they’re always active. A good starting .pymolrc:

set cartoon_fancy_helices, 1
set cartoon_smooth_loops, 1
set ray_opaque_background, 1
bg_color white

These four lines eliminate problems 2 and 9 permanently — you never need to remember to set them again.
When nothing works — reinitialize
If your PyMOL session has gotten into a strange state and nothing looks right, run reinitialize to reset everything to factory defaults, then reload your structure from scratch. Most persistent weirdness disappears after a clean reinitialize — it’s the equivalent of turning it off and on again, but without losing the loaded files.

The pattern behind most PyMOL problems

Nine of these ten problems are either missing a single command (ray_opaque_background, cartoon_fancy_helices, minimum=50), applying commands in the wrong order (coloring before showing surface), or not preprocessing input data (raw MD trajectories). None of them are bugs — they’re all predictable consequences of defaults that weren’t designed for publication figure workflows. Put the four-line .pymolrc setup in place, always preprocess trajectories before loading, and color after showing representations, and you’ll avoid the majority of issues on this list before they happen.

Last updated on

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *