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?
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.
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.