Has this solution consistently solved the problem for you?
I have some scripts such as rhinopython/spb_Brep_filletEdges_in_FreeCAD.py at master · CADacombs/rhinopython · GitHub that subprocesses to FreeCADcmd.exe. From Rhino 8, some/most of the time an error like that below occurs. Only sometimes I have found PYTHONHOME set to the RhinoCode library. Even when it is not, the same error may occur.
stderr from Popen.communicate: Fatal Python error: init_import_size: Failed to import the site module
Python runtime state: initialized
Traceback (most recent call last):
File "\\?\C:\Users\spb\.rhinocode\py39-rh8\lib\site.py", line 73, in <module>
import os
File "\\?\C:\Users\spb\.rhinocode\py39-rh8\lib\os.py", line 29, in <module>
from _collections_abc import _check_methods
File "\\?\C:\Users\spb\.rhinocode\py39-rh8\lib\_collections_abc.py", line 12, in <module>
GenericAlias = type(list[int])
TypeError: 'type' object is not subscriptable