The single best way to improve your chances of getting help is to provide a minimal, reproducible example, that is, a small, fully functional version of what you’re trying to do so that others can run the same code and figure out the problem.
Here is a fully functional example. You can use it as a starting point to build the code that reproduces your error.