matterhorn103/avo_xtb

avo-xtb is unable to download xtb in Windows10

Closed this issue · 7 comments

Machine: Windows 10 and Avogadro2 Nightly Build from 2024-02-06
Plugin installed manually in C:\Users\USER\AppData\OpenChemistry\Avogadro\commands\avo-xtb

Expected behaviour: Finishing the "Get xtb ..." dialogue downloads xtb from the Grimme Group into the user specified directory.
Actual behaviour: Apperently nothing happens, but /avogadro2.log shows some error messages.

Warning: "Unhandled widget in collectOptions for option 'crest_url'." (:0, )

Warning: "Unhandled widget in collectOptions for option 'info'." (:0, )

Warning: "Unhandled widget in collectOptions for option 'license'." (:0, )

Warning: "Unhandled widget in collectOptions for option 'notice'." (:0, )

Warning: "Unhandled widget in collectOptions for option 'xtb_url'." (:0, )

Warning: ("Parse error at offset 1: 'illegal value'\nRaw JSON:\n\nTraceback (most recent call last):\r\n  File \"C:\\Users\\<USER>\\AppData\\Local\\OpenChemistry\\Avogadro\\commands\\avo_xtb\\install.py\", line 173, in <module>\r\n    get_xtb(xtb_url, install_dir)\r\n  File \"C:\\Users\\<USER>\\AppData\\Local\\OpenChemistry\\Avogadro\\commands\\avo_xtb\\install.py\", line 76, in get_xtb\r\n    archive = download(url, install_dir)\r\n              ^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n  File \"C:\\Users\\<USER>\\AppData\\Local\\OpenChemistry\\Avogadro\\commands\\avo_xtb\\install.py\", line 61, in download\r\n    urllib.request.urlretrieve(url, archive_path)\r\n  File \"C:\\Program Files\\Python\\312\\Lib\\urllib\\request.py\", line 250, in urlretrieve\r\n    tfp = open(filename, 'wb')\r\n          ^^^^^^^^^^^^^^^^^^^^\r\nFileNotFoundError: [Errno 2] No such file or directory: 'C:\\\\Users\\\\<USER>\\\\AppData\\\\Local\\\\OpenChemistry\\\\Avogadro\\\\programs\\\\xtb\\\\xtb-6.6.1-windows-x86_64.zip'\r\n") (:0, )

Warning: ("Parse error at offset 1: 'illegal value'\nRaw JSON:\n\nTraceback (most recent call last):\r\n  File \"C:\\Users\\<USER>\\AppData\\Local\\OpenChemistry\\Avogadro\\commands\\avo_xtb\\open.py\", line 63, in <module>\r\n    subprocess.run([\"start\", calc_dir])\r\n  File \"C:\\Program Files\\Python\\312\\Lib\\subprocess.py\", line 548, in run\r\n    with Popen(*popenargs, **kwargs) as process:\r\n         ^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n  File \"C:\\Program Files\\Python\\312\\Lib\\subprocess.py\", line 1026, in __init__\r\n    self._execute_child(args, executable, preexec_fn, close_fds,\r\n  File \"C:\\Program Files\\Python\\312\\Lib\\subprocess.py\", line 1538, in _execute_child\r\n    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,\r\n                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\nFileNotFoundError: [WinError 2] Das System kann die angegebene Datei nicht finden\r\n") (:0, )

It seems that for each backslash in the path four backslashes are used instead of the usual two. Maybe this confuses Windows ?

First of all, thanks for making an issue! It's great to know when things aren't working as they should.

This is interesting. It's a little hard to tell from your log what exactly has gone wrong.

It seems that for each backslash in the path four backslashes are used instead of the usual two. Maybe this confuses Windows ?

The extra backslashes are due to them needing to be escaped in Python and C++. I doubt they are repeated in the actual path that gets given to Windows. And actually, regardless of how many backslashes are actually sent to Windows by the program, as far as I know Windows will simplify them to just \ without a problem.

Machine: Windows 10 and Avogadro2 Nightly Build from 2024-02-06

Would you mind trying with the new 1.99 release and seeing if the problem persists? You made need to remove and reinstall the plugin.

Couple of questions that might help me:

  1. If you go to Configure..., what does it say for "Run calculations in:"?
  2. Are you changing the install directory from the default? What is the default that it suggests?
  3. Does a folder called xtb appear under C:\\Users\USER\AppData\OpenChemistry\Avogadro\commands\avo-xtb?
  4. Do any compressed archives appear in that directory, or anything that looks like it might be a downloaded form of xtb?

Otherwise, I recommend using one of the other methods for xtb installation.

As I mentioned above, I used a user specified path and not the default.
I tried with Avogadro2 1.99 and default settings today and it works as expected.
But when I use my own path, it only works iff the given directory already exists.
I assume that the script is not checking if the user specified path already exists and is not creating the directories if it does not exist, which would be the behaviour expected by me.

Ok, my most recent commit should fix things. The specified install directory is now created if it doesn't already exist. The resulting location of the binary is also saved now too.

Can you download the latest version of the code (via https://github.com/matterhorn103/avo_xtb/archive/refs/heads/main.zip) and try to see if it works as you expect?

The new version works, but only if there is only one directory to be created.

Example: Desination 'C:\Users\USER\AppData\Local\OpenChemistry\Avogadro\programs\xtb'
If subdirectory 'programs' does not exist, it won't create 'programs\xtb'.
If subdirectory 'programs' already exist, it creates the 'xtb' subdirectory as intended.

Maybe 'install_dir.mkdir(exist_ok=True)' is not enough and you need 'install_dir.mkdir(parents=True, exist_ok=True)' ?

Fixed :)

Works beautifully now.
But I am puzzled by one thing:
After xtb is installed, the "path to xtb executable" entry in the Configure... menu is still empty.
Is this the correct behaviour ?

Probably fixed by my commits 3 hours ago!