[lammps-users] Questions related with python's lammps module installation

Dear all,
I have tried to install LAMMPS like these procedures, 1. make mpi mode=shlib yes-python 2. make install-python.
I have found the “liblammps_mpi.so” file in the src dictionary of LAMMPS. But when I run my LAMMPS script
including the Python lammps module. Some errors occurred like that, “ImportError: No module named lammps
ERROR on proc 0: Python function evaluation failed (…/python_impl.cpp:333)”. Is there somebody told me the reasons?
Regards,
Stephen

Please always report the LAMMPS version and the platform you are compiling/running on.

Dear all,
I have tried to install LAMMPS like these procedures,

  1. make mpi mode=shlib yes-python

the LAMMPS manual explicitly says that you must not combine “make yes/no” targets with compilation targets.
also “mode=shlib” is outdated, so you may be following outdated instructions or have an outdated LAMMPS version.

  1. make install-python.

I have found the “liblammps_mpi.so” file in the src dictionary of LAMMPS. But when I run my LAMMPS script
including the Python lammps module. Some errors occurred like that, “ImportError: No module named lammps
ERROR on proc 0: Python function evaluation failed (…/python_impl.cpp:333)”. Is there somebody told me the reasons?

the presence of the liblammps_mpi.so file and the import error are unrelated. the module load error is due to not finding the python module.

rather than calling python from within LAMMPS (which has multiple pitfalls) you should first try to launch python and import the lammps module there and then debug that step.

I also strongly recommend to review the documentation for the python support in the “programmer guide” section of the manual for the current LAMMPS version, which has been significantly expanded and improved over the last year. https://docs.lammps.org/Python_head.html

Axel.

Thanks for your response. I have changed my LAMMPS version to December 2020, and my platform is “Linux DESKTOP-PECIRI9 4.4.0-19041-Microsoft #488-Microsoft Mon Sep 01 13:43:00 PST 2020 x86_64 x86_64 x86_64 GNU/Linux”.
I read the content in your attached link in detail. But please understand that I am not a good Linux user that there is still something unclear to me.
I firstly installed the shared mode LAMMPS using the command “make mode=share mpi” in the src dictionary, then input the command “make install-python”.
I tested like that,
image.png.

I think there must be something wrong. Could you help me figure it out?
Regards,
Stephen

Axel Kohlmeyer <[email protected]> 于2021年2月6日周六 下午10:36写道:

Thanks for your response. I have changed my LAMMPS version to December 2020, and my platform is “Linux DESKTOP-PECIRI9 4.4.0-19041-Microsoft #488-Microsoft Mon Sep 01 13:43:00 PST 2020 x86_64 x86_64 x86_64 GNU/Linux”.
I read the content in your attached link in detail. But please understand that I am not a good Linux user that there is still something unclear to me.

if you have technical difficulties or problems of understanding with the Linux platform, you should find somebody local that has the necessary experience and can help you and address your concerns.

I firstly installed the shared mode LAMMPS using the command “make mode=share mpi” in the src dictionary, then input the command “make install-python”.
I tested like that,
image.png.

I think there must be something wrong. Could you help me figure it out?

there is nothing wrong visible here. this looks like both, compilation and installation, did work as expected.

axel.

When I perform the simulation using a script including a python function, it would report errors. My head and end of python part in the LAMMPSscript are like that respectively,
image.png

image.png.
The terminal window report the error “ERROR: LAMMPS is not built with Python embedded (…/variable.cpp:797)
Last command: python sort_wall input 1 SELF format p here “””
It is really confusing.
Regards,
Stephen

Axel Kohlmeyer <[email protected]> 于2021年2月7日周日 下午10:11写道:

image.png

When I perform the simulation using a script including a python function, it would report errors. My head and end of python part in the LAMMPSscript are like that respectively,
image.png

image.png.
The terminal window report the error “ERROR: LAMMPS is not built with Python embedded (…/variable.cpp:797)
Last command: python sort_wall input 1 SELF format p here “””
It is really confusing.

this is all explained. you are mixing up the python “module” with the python “package”.

when you want to include the python package you:

  • first install the python package into the LAMMPS source code for compilation (e.g. via make yes-python for the conventional make based installation)
  • then compile LAMMPS for the desired machine settings (e.g. make mode=shared mpi)
  • then install the LAMMPS “module” and shared library into the location where python can find it (via make install-python)

quite straightforward, if you think it through. if you don’t do the first step first, your compilation in the second step is missing the feature and that is why the python command won’t work in a LAMMPS input, but the import of LAMMPS as such into a generic python interpreter works (since that is done with the third step).

axel.

image.png

then you did not follow the instructions correctly and fully. your previous e-mails confirm the likelihood of that.

everything about compiling/configuring and installing LAMMPS is documented in the manual.
as I wrote before, if you have difficulties understanding those instructions, you need to get local help from somebody that has the experience that you are lacking.
it is beyond the scope of this mailing list to teach people skills that are independent from LAMMPS, and teaching via e-mail is cumbersome and ineffective to boot.

axel.

image.png

image.png

image.png

Thanks for your detailed guide. Sorry to waste you much time on this issue. I tried to follow these three steps as you suggested. Totally the same commands are inputted. But when I run my LAMMPS script, the same error is reported.
Regards,
Stephen

Axel Kohlmeyer <[email protected]> 于2021年2月7日周日 下午10:27写道:

image.png

image.png

image.png