call python from a lammps input script

Dear lammps-users:
We have some problem in calling python from a lammps input script: we
use the lammps-7Aug19(also try the 3Mar 2020)/python 3.7 on centos7.6,
we install them with the orders: $make yes-python $make serial $make
mpi, and it can run normal test file correctly. Calling lammps from
python works fine and python commend works fine too. But when we test
the example that need callback from lammps, errors happen. For
example, we test 'in.fix_python_invoke' in example/python with $mpirun
-np 4 lmp_serial < in.fix_python_invoke,error comes like this:

ERROR: Could not process Python string (../python_impl.cpp:227)
Last command: python end_of_step_callback here """
from __future__ import print_function
from lammps import lammps
def end_of_step_callback(lmp):
  L = lammps(ptr=lmp)
  t = L.extract_global("ntimestep", 0)
  print("### END OF STEP ###", t)
def post_force_callback(lmp, v):
  L = lammps(ptr=lmp)
  t = L.extract_global("ntimestep", 0)
  print("### POST_FORCE ###", t)
"""
We don't know what happened and how to fix it. We are looking forward
to your helps, any advice will be helpful!

Thanks a lot!

Enabling the PYTHON package in LAMMPS does not install the python module (lammps.py), which you are using.
Please check the documentation:
https://lammps.sandia.gov/doc/Python_install.html