Pycapsule error on ipylammps in jupyter

Could someone please give me some hints here? Not sure what is wrong, the manual says that this should work in jupyter provided that lammps is installed with the same python interpreter that anaconda uses, which I tried to do.

I am using windows 11 and I also have installed lammps three times, once with the windows executable, once with the wsl guide, and also using the linux ubuntu guide in the wsl terminal.

This may be the problem here. When you install the “LAMMPS with Python” installer package, it comes with its own python interpreter. Have you tried installing the version without Python?
That should still provide PyLammps and the LAMMPS python module. The only feature missing is to call out to python using python style variables or fix python functions or the python pair style.

I tried to uninstall and reinstall with LAMMPS-64bit-latest.exe and it’s giving me the exact same problem. Not sure how to check which python interpreter I am using but juptyter works fine to import lammps, it’s just IPyLammps giving me a problem.

Well, it has never been tested when it was written. Most of LAMMPS is only written and tested on Linux machines and to a lesser degree on MacOS machines. Windows is mostly done via cross-compilation. It is only a very recent development that you can compile LAMMPS as a DLL file for dynamic loading and thus supporting the python interface.

We currently have nobody in the LAMMPS developer team with the experience to resolve this.

Thanks for your response, I managed to create a PyLammps object in jupyter, was wondering if you’ve seen this error before?

No.

The problem seems to be an issue with passing the (binary) handle to the LAMMPS DLL file between PyLammps and lammps. I have been able to make this work by compiling LAMMPS from source on Windows with the Visual Studio compilers and the python package from python.org (I did not install the Visual Studio Python package). This will fail with the “dump image” command, because the native build Windows build currently does not include the PNG image file format (would need to be included into the LAMMPS build for windows, but that is not yet supported. The cross-compiler build has those libraries available).

If you get the “lammps” class to work, I would recommend to stick with it. PyLammps does not really add any (LAMMPS) functionality to it.