Trouble running python function from lammps

Hello again,

I am trying to use python scripts to perform a more difficult calculation on data during a LAMMPS script, but I am having a problem getting it to run correctly.

I have downloaded the “LAMMPS 64-bit 22Jul2025 with Python” version for Windows and no matter what script I try running, lammps crashes and I get the following output:

  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\User\AppData\Roaming\Python\Python312\Scripts\lmp.exe\__main__.py", line 2, in <module>
  File "C:\Users\User\AppData\Local\LAMMPS 64-bit 22Jul2025 with Python\Python\lammps\__init__.py", line 54, in <module>
    __version__ = get_version_number()
                  ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\User\AppData\Local\LAMMPS 64-bit 22Jul2025 with Python\Python\lammps\__init__.py", line 51, in get_version_number
    t = time.strptime(vstring, "%Y.%m.%d")
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python312\Lib\_strptime.py", line 549, in _strptime_time
    tt = _strptime(data_string, format)[0]
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python312\Lib\_strptime.py", line 336, in _strptime
    raise ValueError("unconverted data remains: %s" %
ValueError: unconverted data remains: .4.0

I have attempted a few, including from the examples in the documentation. Even just running this:

python python_hello input 1 SELF format p here """
def python_hello(handle):
    from lammps import lammps
    lmp = lammps(ptr=handle)
    me = lmp.extract_setting('world_rank')
    if me == 0:
        print('Hello, LAMMPS!')
"""

python python_hello invoke

causes the above error to appear.

I presume I have set something up incorrectly. Could you suggest what I might be doing wrong?

Thank you for your time.

@ipetranovic Thanks for your report.

I cannot think of anything. The Windows installer packages are supposed to be self-contained.

If there would really be a setup issue, then it has to be something outside of LAMMPS and that is something that nobody can know but you and thus you would be stuck with having to sort that out yourself.

Before I start taking a closer look (checking out issues on Windows always takes extra time since I work 99% of the time on Linux and even the Windows packages are built on Linux with a cross-compiler… :wink:), can you confirm that you are using the latest stable version update, e.g. this one: https://rpm.lammps.org/windows/LAMMPS-64bit-Python-22Jul2025_update4.exe?
If that is true, can you try out the latest feature release version: https://rpm.lammps.org/windows/LAMMPS-64bit-Python-30Mar2026.exe?

This way you can make certain that I am not going to investigate an issue that has already been resolved.

Thanks in advance.

1 Like

Unfortunately, I work with what I am given. I have access to a cluster that runs Linux, but the work computers are all Windows. The cluster has admins that install packages, but for brief testing/learning I have to install stuff myself.

I have attempted to reinstall with the link you have provided and the behaviour is still the same. Meanwhile, I have installed it on a different computer using the same file and it seems to be working.

I am not that tech savvy, but my best guess would be that multiple Python installations somehow got confused, but I don’t know how. I will have to leave that to you if you wish to continue investigating. I am willing test some more stuff if you need.

Oh, and, of course, thank you for the time.