# Problem installing gmxapi on Ubuntu

**URL:** <https://gromacs.bioexcel.eu/t/problem-installing-gmxapi-on-ubuntu/13289>\
**Category:** User discussions\
**Tags:** gmxapi, installation, installation-error\
**Created:** [March 8, 2026, 6:52pm UTC](https://gromacs.bioexcel.eu/t/problem-installing-gmxapi-on-ubuntu/13289 "2026-03-08T18:52:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![pippo1980](https://avatars.discourse-cdn.com/v4/letter/p/4af34b/32.png) [@pippo1980](https://gromacs.bioexcel.eu/u/pippo1980)\
**Post date:** [March 8, 2026, 6:52pm UTC](https://gromacs.bioexcel.eu/t/problem-installing-gmxapi-on-ubuntu/13289/1 "2026-03-08T18:52:12Z")

</div>

GROMACS version: GROMACS - gmx, 2023.3-Ubuntu\_2023.3\_1ubuntu3  
GROMACS modification: No

Hi Dears, hope this finds you well,

apologize for yet another installation question.

My set up : Ubuntu 24.04.04 LTS

I got GROMACS as gmx, 2023.3-Ubuntu\_2023.3\_1ubuntu3 from ubuntu repo (apt install gromacs)

I guess it came already compiled.

which gmx reports /usr/bin/gmx

I am trying to install gmxapi but get the orrible/terrible :

Failed to build gmxapi  
error: failed-wheel-build-for-install

× Failed to build installable wheels for some pyproject.toml based projects  
╰─\> gmxapi

somewhere up in the log:

The `gmxapi` package requires an existing GROMACS installation, version 2020 or higher.  
If the usual GROMACS environment variables are detected (such as from sourcing GMXRC),  
the corresponding GROMACS installation will be used. Otherwise, provide CMake options  
to the Python package installer.  
Define `gmxapi_ROOT` to the GROMACS installation directory (`-Dgmxapi_ROOT=/path/to/gromacs`).  
Help CMake find the GROMACS compiler toolchain with `-C /path/to/gromacs/share/cmake/gromacs/gromacs-hints.cmake`.

tried with :

gmxapi\_ROOT=usr/bin/gmx pip install --no-cache-dir gmxapi==0.4.0

(0.4.0 seemed the one same age of Gromacs 2023, but gget same results with latest versioN)

but no luck.

I dont understand a lot of this, but question is :

is there any way to solve it or have I to build/install gromacs from scratch ?

in the latter case what should I do to be sure to be able to install gmxapi afterward ?

ANd moreover ( feel really dumb for this) what is GMXRC cited above ?

Cheers

P.

---

<div class="post-metadata">

**Author:** ![ericirrgang](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/ericirrgang/32/438_2.png) [@ericirrgang](https://gromacs.bioexcel.eu/u/ericirrgang)\
**Post date:** [March 8, 2026, 11:17pm UTC](https://gromacs.bioexcel.eu/t/problem-installing-gmxapi-on-ubuntu/13289/2 "2026-03-08T23:17:30Z")

</div>

Hello, P.

I have not used the gromacs ubuntu package before, but it doesn’t look like it provides a sufficient installation. I also tried installing the `libgromacs-dev` package, but it did not provide `libgmxapi` or the cmake infrastructure, as best I can tell. (It also does not provide a GMXRC file.)

gromacs has to be configured with `-DGMXAPI=ON` when it is built to support gmxapi. This option is normally ON by default, but was apparently disabled in the ubuntu package, and I don’t see an ubuntu package option that has the missing pieces.

The gmxapi installation instructions ([Full installation instructions - GROMACS 2026.1 documentation](https://manual.gromacs.org/current/gmxapi/userguide/install.html)) include links to other documentation about configuring, building, and installing gromacs appropriately.

I think if you install gromacs from source code, it will go more smoothly. You can download the source code from [Downloads - GROMACS 2026.1 documentation](https://manual.gromacs.org/documentation/current/download.html)

For more information on the GMXRC file, see [Installation guide - GROMACS 2026.1 documentation](https://manual.gromacs.org/current/install-guide/index.html#getting-access-to-gromacs)

Sorry for the trouble! Good luck!

---

<div class="post-metadata">

**Author:** ![pippo1980](https://avatars.discourse-cdn.com/v4/letter/p/4af34b/32.png) [@pippo1980](https://gromacs.bioexcel.eu/u/pippo1980)\
**Post date:** [March 11, 2026, 8:35am UTC](https://gromacs.bioexcel.eu/t/problem-installing-gmxapi-on-ubuntu/13289/3 "2026-03-11T08:35:12Z")

</div>

had to build/install latest cmake and gromacs as per instructions,

needed to install openmpi-bin libopenmpi-dev

used

gmxapi\_ROOT=/usr/local/gromacs/ pip install --no-cache-dir gmxapi

and everything seems fine.

gmx

returns

:-) GROMACS - gmx, 2026.1 (-:

import gmxapi

print('gmxapi version : ', gmxapi. **version** )

prints gmxapi version : 0.4.2

but trying to run pytest:

cd python\_packaging/gmxapi  
pip install -r requirements.txt  
pytest test

gives : ImportError: Error importing plugin “gmxapi.testsupport”: No module named ‘gmxapi’

while in python :

from gmxapi import testsupport

print('gmxapi.testsupport : ', gmxapi.testsupport)

gives: gmxapi.testsupport : \<module ‘gmxapi.testsupport’ from ‘/xxx/xxx/xxx/xx/myenv/GMXAPI\_spyder/lib/python3.12/site-packages/gmxapi/testsupport.py’\>

can run it from inside python with

python

\>\>\>\> import pytest

\>\>\>\> pytest.main([“test”])

and unfortunately got:

platform linux – Python 3.12.3, pytest-9.0.2, pluggy-1.6.0  
rootdir: /xx/xxx/xxx/GROMACS/gromacs-2026.1/python\_packaging/gmxapi/test  
configfile: pytest.ini  
collected 41 items

test/test\_commandline.py …F… [29%]  
test/test\_exceptions.py . [31%]  
test/test\_feature\_check.py .ss [39%]  
test/test\_fileio.py … [46%]  
test/test\_fileio\_low\_level.py … [53%]  
test/test\_mdrun.py …s.s.. [73%]  
test/test\_operation.py … [82%]  
test/test\_runtime.py … [92%]  
test/test\_subgraph.py … [100%]

================================================================================= FAILURES =================================================================================  
\_ **\_ test\_command\_with\_input\_files \_** \_\_

cleandir = PosixPath(‘/tmp/pytest-of-opw/pytest-1/test\_command\_with\_input\_files0’)

```auto
def test_command_with_input_files(cleandir):
    """Test handling of *input_file* arguments.
    
        Generate a file and provide it as a relative path to a simple command line tool.
        Confirm that the relative path (valid for the script working directory but not
        for the Task working directory) is correctly normalized to an absolute path.
    
        Check for #4827 regression.
        """
        with tempfile.NamedTemporaryFile(mode="w", delete=False) as fh:
            fh.write("hi\nthere\n")
            fh.flush()
        assert fh.closed
        actual_path = Path(fh.name).resolve()
        try:
            with open(actual_path, "r") as fh:
                num_lines = len(fh.readlines())
            relative_path = os.path.relpath(actual_path, start=cleandir)
            # Overload the input files facility to trigger path normalization.
            # `wc` implementations are fairly consistent as far as providing a
            # `-l` option and accepting a positional file argument.
            cmd = commandline.commandline_operation(
                executable="wc", input_files={"-l": relative_path}
            )
            # We want to find a relative path from the current directory that would
            # not resolve correctly from the generated Task directory. We will now
            # double-check that the relative path _would have_ caused the test to fail
            # if the absolute path conversion (#4827) were not working correctly.
            workdir = cmd.output.directory.result()
            assert not Path(workdir).joinpath(relative_path).exists()
            # Uncomment the following for additional debugging.
            # actual_relative_path = os.path.relpath(actual_path, start=workdir)
            # returncode = cmd.output.returncode.result()
            # error = cmd.output.stderr.result()
    
            # Check that the file whose lines we counted has the expected number of lines.
            output = cmd.output.stdout.result()
            # For `wc -l filename` on a 2-line file, we expect output
            # similar to " 2 filename\n".
            # Check the first non-whitespace field.
> assert output.split()[0] == str(num_lines)
                   ^^^^^^^^^^^^^^^^^
E IndexError: list index out of range

/xxx/xxx/xxx/GROMACS/gromacs-2026.1/python_packaging/gmxapi/test/test_commandline.py:172: IndexError

```

looks llike is failing where it could be of help (running gromacs from python using files as args of commands !!??)

Any help here too ? Or should I create a new question

Thanks a lot

PS

trying to understand more it’s like after

cmd = commandline.commandline\_operation(  
executable=“wc”, input\_files={“-l”: relative\_path}  
)

there is no cmd.run() line in test\_commandline.py , but even adding it the test keeps failing

blabbing about some non existent file

error : /usr/bin/wc: pippo.txt: No such file or directory

---

<div class="post-metadata">

**Author:** ![ericirrgang](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/ericirrgang/32/438_2.png) [@ericirrgang](https://gromacs.bioexcel.eu/u/ericirrgang)\
**Post date:** [March 12, 2026, 4:26am UTC](https://gromacs.bioexcel.eu/t/problem-installing-gmxapi-on-ubuntu/13289/4 "2026-03-12T04:26:19Z")

</div>

Glad you made progress!

For the `pytest test` command line, my guess is that the `pytest` command is probably in a different environment or virtual environment than your `pip` command. You can try doing `pip install –upgrade pytest` to make sure that the pytest entry point is in the same environment that you installed gmxapi into, or you could invoke pytest as `python -m pytest` instead of just `pytest`.

As far as the failing test, the main difference I see from [https://gitlab.com/gromacs/gromacs/-/jobs/13459460957](https://gitlab.com/gromacs/gromacs/-/jobs/13459460957) is that you are using a newer version of Python. It is possible that the main project testing needs to be updated to catch behavior changes in newer versions of Python.

I’m surprised that the temporary filename that was generated would be “pippo.txt” instead of something more random-looking, but it seems like something might be going wrong in the path handling or file staging. I’ll try to take a look soon, but you can look at the working directories and “task directories” if you want to try to figure out what is going on.

The `output` should have been generated at the time that `result()` was called. (No explicit call to `run()` should be necessary.)

However, the relative path should have been normalized to an absolute path when `commandline.commandline_operation()` was called, but it seems like that might not have happened.

For more information about the intended behavior, see [gmxapi.commandline\_operation has potentially confusing behavior with relative paths in \*input\_files\* parameter (#4827) · Issues · GROMACS / GROMACS · GitLab](https://gitlab.com/gromacs/gromacs/-/work_items/4827) and [Clarify `gmxapi.commandline_operation()` behavior re: \*input\_files\* (!3704) · Merge requests · GROMACS / GROMACS · GitLab](https://gitlab.com/gromacs/gromacs/-/merge_requests/3704)

This does not sound like an installation problem. It could warrant a bug report (see [Change Management - GROMACS 2026.1 documentation](https://manual.gromacs.org/current/dev-manual/change-management.html#creating-issues)). At the very least, more recent Python versions should be added to the automated testing jobs.

---

<div class="post-metadata">

**Author:** ![pippo1980](https://avatars.discourse-cdn.com/v4/letter/p/4af34b/32.png) [@pippo1980](https://gromacs.bioexcel.eu/u/pippo1980)\
**Post date:** [March 12, 2026, 10:59pm UTC](https://gromacs.bioexcel.eu/t/problem-installing-gmxapi-on-ubuntu/13289/5 "2026-03-12T22:59:47Z")

</div>

yep `pytest` was installed systemwide added to virtualenv too

temp file was “pippo.txt” because was trying to figure out if something was wrong with `File.NamedTemporaryFile`

got test working with changing :

`cmd = commandline.commandline_operation(`  
` executable=“wc”, input_files={“-l”: relative_path}`  
`)`

to

```auto
    cmd = commandline.commandline_operation(
        executable="wc", input_files={"-l": actual_path}
    )

```

results gives (`output = cmd.output.stdout.result()`):

`output : 2 /tmp/pytest-of-opw/pytest-78/test_command_with_input_files0/pippo.txt`

### **NOT SURE IF IT DEFIES THE GOAL OF THE TEST THOUGH**!!!

_[could try to change relative\_path = os.path.relpath(actual\_path, start=cleandir) with_

_relative\_path = os.path.relpath(actual\_path, start=os.curdir)) to save the logic ???]_

I noticed that using:

`cmd = commandline.commandline_operation(`  
`executable=“wc”, arguments=[‘-l’], input_files={“”: actual_path}`  
`)`

I get:

`output : 2 /tmp/pytest-of-opw/pytest-79/test_command_with_input_files0/pippo.txt`  
`2 total`

looks like using:

`wc -l “” pippo.txt`

Now I understand [gmxapi.commandline\_operation](https://manual.gromacs.org/current/gmxapi/userguide/pythonreference.html#gmxapi.commandline_operation) better than reading :

> **input\_files** – mapping of command-line flags to input file paths

No clues about:

> The `output` should have been generated at the time that `result()` was called. (No explicit call to `run()` should be necessary.)

Thanks for your help (time and patience)

Is there any way to mark the discussion as solved ? like stack overflow ?

---

<div class="post-metadata">

**Author:** ![ericirrgang](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/ericirrgang/32/438_2.png) [@ericirrgang](https://gromacs.bioexcel.eu/u/ericirrgang)\
**Post date:** [March 13, 2026, 1:04am UTC](https://gromacs.bioexcel.eu/t/problem-installing-gmxapi-on-ubuntu/13289/6 "2026-03-13T01:04:17Z")

</div>

It’s good to know that it works when you use an absolute path.

The test is supposed to confirm that a relative path is properly handled, too. Since it fails with a relative path, it sounds like there is a bug that needs to be fixed to restore the intended behavior in more recent versions of Python.

Thank you for reporting and taking the time to track it down!
