Python file not processed when calling from LAMMPS using specific packages

Hi everyone,

I’m trying to call a function from a python file in a LAMMPS input file, but I keep getting “ERROR: Could not process Python file (…/python_impl.cpp:226)” in the log file.
I am using the following mock py script to test and managed to find that the scipy.spatial and sklearn.cluster packages are the ones crashing the simulation:

import sys
import os
import numpy as np
from sklearn.cluster import AgglomerativeClustering
from scipy.spatial import ConvexHull

def Empty(a):
    b = a+1
    return b

Doing “import scipy” in the .py file works fine when calling from LAMMPS, but these specific packages are not working.
The code can be run independently without problems, and I’ve made sure that scipy.spatial and sklearn.cluster can be loaded in python without errors as well.
I’m using the lammps-23Jun2022 version and python 3.7.15

Are there any particular strategies that I can try to fix this problem?

This doesn’t look like a LAMMPS specific issue.
What is the output before “ERROR: Could not process Python file (…/python_impl.cpp:226)"?

That should provide a clue about what is happening.