Skip to content

AttributeError: module 'gromacs.tools' has no attribute 'Grompp' when using gmx_mpi only #262

@oliviertrottier

Description

@oliviertrottier

Hi,
I am fairly new to using Gromacs and stumbled upon the gromacswrapper package, which I find super useful and well documented. I wanted to use some of the cookbook recipes, but I am not able to load cbook. Here is the error message I get when I try to import cbook from gromacs:

/home/olivier/anaconda3/envs/gmx-sim/lib/python3.11/site-packages/gromacs/cbook.py:229: GromacsImportWarning: Failed to define a number of commands in gromacs.cbook. Most likely the Gromacs installation cannot be found --- set GMXRC in ~/.gromacswrapper.cfg or source GMXRC directly
  warnings.warn(msg, category=GromacsImportWarning)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[396], line 1
----> 1 from gromacs import cbook

File ~/anaconda3/envs/gmx-sim/lib/python3.11/site-packages/gromacs/cbook.py:668
    659             self.cleanup()
    662 # Working with topologies
    663 # -----------------------
    664 
    665 # grompp that does not raise an exception; setting up runs the command to get the docs so
    666 # we only want to do this once at the module level and not inside a function that can be called
    667 # repeatedly
--> 668 grompp_warnonly = tools.Grompp(failure="warn")
    669 # grompp_warnonly.__doc__ += "\n\ngrompp wrapper that only warns on failure but does not raise :exc:`GromacsError`"
    672 def grompp_qtot(*args, **kwargs):

AttributeError: module 'gromacs.tools' has no attribute 'Grompp'

Here are my configurations in ~./gromacswrapper.cfg.

[Gromacs]
GMXRC = /usr/local/gromacs/bin/GMXRC
tools = gmx_mpi

I only have one gromacs installation, which is the _mpi version. I noticed that all the attributes are suffixed with _mpi. That seems to be the cause of the problem since python cannot find the non-suffixed version. Is there a way to use the gromacswrapper classes in a gromacs-command-agnostic way? I would like to write one codebase that I can use for multiple gromacs installations without having to change the suffix of all the attributes that I am using.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions