Hi, everyone!
This is my first time to use lammps python interface and one problem occurs when I run in.python in examples/python directory.
I compile the LAMMPS-5Nov2016 version source code into a shared library. No error occurs when compiling. Then set the two environmental variables in my .bashrc file like this:
export PYTHONPATH=/public2/home/qzy/soft/LAMMPS/lmp-5Nov16/python:$PYTHONPATH
export LD_LIBRARY_PATH=/public2/home/qzy/soft/LAMMPS/lmp-5Nov16/src:$LD_LIBRARY_PATH
After this, I go to run the examples under python/examples, for example, type “python -i simple.py in.simple” in my shell terminal.
It is successful. Then I go to run the in.python under examples/python directory. The first two python functions are completed with no error. When it run the third python function, an error is thrown that “Error on proc 0: Python function evalution failed (…/python.cpp: 247)”. So I write some print command in the python code file (that is, funcs.py) to debug. I found that it stopped at the line “natoms=lmp.get_natoms()”, that is, it can’t perform lammps command from python code. To test more, I run the plain python and type:
from lammps import lammps
lmp=lammps()
lmp.command(" print ‘Hello from inside Python’")
Hello from inside Python
it seems good.
So I don’t know why it fails when the lammps library function are called using the callback mechanism.
Any suggestions are welcomed and appreciated. Thank you for your time.
Best
Z. Y. Qiu