Xtb plugin installation

Ah. This might be a very easy fix after all. Basically, you need a newer version of Python. It seems yours is at least four years old.

The error is because the scripts use a feature that’s only been in Python since version 3.10. Presumably you are using an older version (you can check with python --version).

Just so that we are sure that the command python is invoking the relevant interpreter, maybe also try:

C:\Program Data\Anaconda3\python.exe --version
C:\Program Data\Anaconda3\python.exe energy.py --menu-path

I’d recommend just getting normal Python 3.12 or 3.13 (just released) from Python Releases for Windows | Python.org, installing it, then changing your Python settings in Avogadro to point to the new, up-to-date Python you’ve just installed. To me that seems easiest.

If you’d rather stick with Conda, that’s fair enough, you’ll just need to upgrade the Python that your Conda installation has – see here for some help on how. The easiest way might be just to reinstall Conda/Anaconda.

You are absolutely right! I have the version 3.9.13, so I will install the new version and report the result in a follow up message.

1 Like

After uninstalling Anaconda (with the old Python), and installing the new Python as you suggested (without Anaconda), I get the following xtb menu:


However, after experimenting a bit with the protonation problem I started with, I still see a couple of suspicious features:

  1. My Python settings look as follows:

    and always revert to the default (highlighted in blue) after each run. With this default, xtb optimisation does not produce any visible result. If I manually change to the second option that is correctly recognised as the 3.13.0 version, optimisation works and the result maybe makes sense - I need to experiment more or use some xtb benchmarks to check - could you, perhaps, suggest a test run?
  2. The partial charges in atomic properties still sum up to strange total, for example +1 in a triply protonated molecule. If this feature does not work, how can I extract the partial charges from the xtb calculation?
  3. Clicking “Go to calculation files” within xtb leads to “Processing” message with the default Python and to no result at all with the correctly recognised Python

The default Python is an existing file created on 13.07.2024, so it cannot belong to the old Python that I uninstalled, but still it does not work…

The fact that Avogadro doesn’t stick to your explicit choice of Python interpreter is weird and a bug, so best if @ghutchis takes a look at that at some point.

  1. If it works, it should be the correct result. If you want to test it to be absolutely certain, your best option is to navigate to the directory containing the calculation files (.../Local/OpenChemistry/Avogadro/commands/avo_xtb/last/); you can study the output file there, and you can run xtb on the input.xyz file there yourself from the command line. Or you can export the input geom from Avogadro as an xyz file and run xtb on that from the command line.
  2. Partial charges aren’t being passed back to Avogadro at the moment, if I remember rightly. I’ll look at adding that ASAP. In the meantime you can always look at the output file yourself, they’ll be in there I should think.
  3. That’s frustrating, I don’t know why that shouldn’t work. I’ll look into it.

The default Python that is being picked up is, I’m pretty sure, a version of Python installed from the Microsoft Store. You should thus be able to uninstall it via the Store app.

Yes, it’s almost certainly showing MMFF94 or Gasteiger charges. IIRC both of those models don’t really handle multiple-charged ions.

Yes, sounds like it’s not getting set in the settings, so it reverts to the python it finds in the PATH (i.e., the WindowsApps version).

Thank you very much for confirming the source of the partial charges.

Regarding the Python behaviour, should I then edit the PATH to get the desired result?

No, it’s definitely an Avogadro bug - it should remember the one you pick in the dialog.

Thank you! I found the output, but is there a way to set the output directory before the calculation is performed?

Partial charges were confirmed by Geoff, so all clear there.

Yes, it would be great of you could look into the (3) functionality, thanks!

OK, got it, but does it mean you would be able to correct it soon, so I should not worry about a work-around?

There’s now a newer version of the plugin, 0.5, that has been significantly rewritten and should hopefully be more robust. If the “Go to calculation files” command still doesn’t work, I’d be very keen to know that.

Many apologies for not noticing your last message earlier!

I had to make a break in my Avogadro-xTB activity and I now see that there is a new xtb plugin version - many thanks! Before I try the new version, one silly question, please. I see from the extensions menu that the current xtb plugin version is 0.6.0 - if I just try to download it from this menu, will it know that it should substitute the existing one or should I uninstall the old plugin in some way? Many thanks!

Yes, it will replace the files from the previous version.

1 Like

Here is my report on the behaviour of the 0.6 version of the xtb plugin:

I downloaded and plugin and used the “get xtb” option. However, after relaunching Avogadro2, I still do not have the xtb optimisation etc. options, but see the “get xtb” as if I have not executed it. In the Configure menu of the xtb, I see that the probable reason is that the location of the xtb executable is missing:


Here are my xtb folders as seen on windows explorer:

Would be great to know how to make the 0.6 version work, thanks a lot!

Hmm. Odd.

No actually, even though it looks like that – that’s an Avogadro bug that will be fixed once we move to Qt6 behind the scenes (hopefully by the 1.100 release). The first box in all the plugin’s dialogs will be emptied for you even if the plugin tried to populate it, I’m afraid, but usually the plugin does have a value stored for it. You can always check e.g. the location the plugin has for the xtb binary in C:/Users/vaverbuk/AppData/Local/easyxtb/config.json

It looks like “Get xtb” isn’t working and isn’t fetching xtb for you at all. Which is weird and not good. If it’s a bug I’d like very much to fix it…

When you click “Get xtb”, does a dialog appear?

The dialog that appears should have a box with the label “Install in:”. I imagine that box is empty for you, just like the first box of the Configure dialog. Make sure you put a path in there before you click ok. If there was no bug the box would be populated by the default path C:/Users/vaverbuk/AppData/Local/easyxtb/bin so I’d suggest you use that.

After clicking ok, a little loading message Processing Get xtb... should appear to let you know it’s working on it. If that doesn’t pop up, it’s not working.

I checked the contents of the config.json file and here they are:
{
“solvent”: null,
“energy_units”: “kJ/mol”,
“method”: 2,
“opt_lvl”: “normal”,
“n_proc”: 3,
“calc_dir”: “C:\Users\vaverbuk\AppData\Local\easyxtb”,
“version”: “0.6.0”,
“xtb_bin”: “.”
}
which I read as “look for the xtb_bin right here”.

I found the xtb executable here:


which probably means that xtb is fetched by the plugin, doesn’t it?

The xtb behaviour changed from the last attempt for the reason that is unclear to me. Now I do have all the options in the xtb menu, but clicking Optimize does not lead to any optimization - nothing happens. On the contrary, Go To Calculation Files does work - it starts a new window of Windows Explorer that opens the easyxtb directory. The “last” subdirectory, however, contains only the input geometry file and no output…

Choosing a different Python location does not change this behaviour.

I will reboot the laptop and try to see if any system update changes this, after which I will add another comment in this thread.

Just a quick update, reboot and system update did not change anything - all the right xtb options appear, but xtb calculations are not executed when these options are used. Apart from the Go To Calculation Files that still works perfectly…

Yep, you’re right.

Out of interest, what are the contents of C:\Users\vaverbuk\AppData\Local\easyxtb\bin?

I was trying to do a bit of a trick with linking that is meant to work on Windows but I wasn’t able to check it. That could be the issue. If so I can fix it.

Try setting "xtb_bin" in config.json to the file you showed in your screenshot C:\Users\vaverbuk\AppData\Local\easyxtb\bin\xtb-dist\bin\xtb.exe and it’ll probably work :slight_smile:

Here is what is in the \bin directory:




I will try the remedy you suggested and report in a separate comment.

1 Like

The change you suggested had an unexpected effect - now I lost all the xtb options apart from Help:


This is after restarting Avogadro.

That’s weird. Can you send the contents of config.json as they now stand?