Xtb-energy Plugin Depends on Python Environment

I have noticed a strange behavior of the xtb energy calculators in Linux. Namely, the performance of the plugin depends on the python environment of the shell where the code is launched (with the same python path in the Python Settings widget). When I run Avogadro2 from a terminal with Python 3.10.12, the plugin does not work, with the following message (repeated over and over in the terminal):

QIODevice::write (QProcess): device not open

The optimizer does not change the structure, while the dynamics move the atoms randomly (likely due to the thermostat), destroying the structure.

Instead, when I activate a conda environment with Python 3.11.7, the plugin works correctly. Related to the issue Molecular distortion during xtb optimization in Nightly 1.103.0 , in this latter case, the optimization runs smoothly. I tried benzene, and got the right planar structure after optimization.

We strongly recommend using pixi for managing plugins. It will install a virtual environment for each plugin with an appropriate version of Python.

If you’re switching python environments .. I have no idea what would happen. The xtb-energy plugin requires the xtb-python package to operate. Do you have that installed in both environments?

I installed pixi outside the conda environment, and the QIODevice::write (QProcess): device not open warning disappeared. However, the core issue remains: the xtb energy does not seem to be computed correctly (it is either not set or effectively zero), and running Dynamics leads to the molecule breaking apart.

I then attempted to reinstall the plugin, but this made things worse. At this point, it is no longer working even within the conda environment where it previously did.

I am currently investigating the issue further and will report back once I have a clearer understanding of the cause. For completeness, I have also reinstalled xtb-python using conda, but the problem persists.

Molecular distortion during xtb optimization in Nightly 1.103.0 - General Discussion / Support - Avogadro Discussion

I would like to add my report regarding the issue mentioned above.

This issue was first observed while using Python 3.12.7 with Anaconda3 on Windows 11. Although switching to Python 3.11.11 initially seemed to resolve the problem, the bug reappeared after I restarted my PC, and now the optimization fails to work correctly on either version.

I have even tried installing previous nightly builds of Avogadro2 that I had downloaded in the past, but the results remain the same, which leads me to believe the issue is related to the Python environment itself. Interestingly, I have tested this across three different computers, and while xTB geometry optimization works perfectly on two of them, the problem is isolated to this specific machine despite all of them running Windows 11 and similar Anaconda setups.

Just dropping a link to my reply in the other post, in case anyone stumbles across this one looking for some answers.

TL;DR, It’s probably a problem with the conda version of xTB (at least for the Windows folks).

I’m not sure if that is the answer here, actually. I suspect it’s something different.

1 Like

Ugh, that’s not great. Fortunately, we have a way to fix this up for @matterhorn103 - plugins can run a setup script, e.g.

avogadro-ani-energy-setup = "avogadro_ani_energy:setup"

So avo_xtb could run a setup script that downloads the xtb package on Windows.

Yep, that’s probably what I’ll do, since Pixi doesn’t seem to have any way to add binary dependencies, as far as I can tell.

Well, in this case, it’s not so much a pixi thing - it’s that the conda-forge build for Windows has bugs (vs. the “official” release).

The root problem is that the conda-forge builds should be correct and reliable.

Yes, I know, I’m saying it’d be useful if I could just specify the URL of the GitHub build as the source of the xtb dependency on Windows.