Python c API error importing tensorflow in editor

Hi,

I’m currently trying to import tensorflow using the Python C Api, I’ve added the include and library paths in build.cs and I’m using Python 3.7.4 and tensorflow 2.0.0.

If i try to run the game in editor the first time i get the following stacktrace:

 Error: ___ Traceback (most recent call last):
  File "C:\Program Files\Python37\lib\site-packages\tensorflow\__init__.py", line 98, in <module>
    from tensorflow_core import *
  File "C:\Program Files\Python37\lib\site-packages\tensorflow_core\__init__.py", line 40, in <module>
    from tensorflow.python.tools import module_util as _module_util
ModuleNotFoundError: No module named 'tensorflow.python.tools'; 'tensorflow.python' is not a package

The second time:

Error: ___ Traceback (most recent call last):
  File "C:\Program Files\Python37\lib\site-packages\tensorflow\__init__.py", line 98, in <module>
    from tensorflow_core import *
  File "C:\Program Files\Python37\lib\site-packages\tensorflow_core\__init__.py", line 45, in <module>
    from tensorflow._api.v2 import compat
  File "C:\Program Files\Python37\lib\site-packages\tensorflow_core\_api\v2\compat\__init__.py", line 23, in <module>
    from tensorflow._api.v2.compat import v1
  File "C:\Program Files\Python37\lib\site-packages\tensorflow_core\_api\v2\compat\v1\__init__.py", line 40, in <module>
    from tensorflow._api.v2.compat.v1 import experimental
  File "C:\Program Files\Python37\lib\site-packages\tensorflow_core\_api\v2\compat\v1\experimental\__init__.py", line 11, in <module>
    from tensorflow.python.ops.control_flow_v2_toggles import output_all_intermediates
  File "C:\Program Files\Python37\lib\site-packages\tensorflow_core\python\ops\control_flow_v2_toggles.py", line 24, in <module>
    from tensorflow.python.ops import control_flow_util_v2
  File "C:\Program Files\Python37\lib\site-packages\tensorflow_core\python\ops\control_flow_util_v2.py", line 28, in <module>
    from tensorflow.python.keras.engine import base_layer_utils
  File "C:\Program Files\Python37\lib\site-packages\tensorflow_core\python\keras\__init__.py", line 27, in <module>
    from tensorflow.python.keras import applications
  File "C:\Program Files\Python37\lib\site-packages\tensorflow_core\python\keras\applications\__init__.py", line 25, in <module>
    from tensorflow.python.keras import engine
  File "C:\Program Files\Python37\lib\site-packages\tensorflow_core\python\keras\engine\__init__.py", line 23, in <module>
    from tensorflow.python.keras.engine.base_layer import Layer
  File "C:\Program Files\Python37\lib\site-packages\tensorflow_core\python\keras\engine\base_layer.py", line 57, in <module>
    from tensorflow.python.keras.saving.saved_model import save as saved_model
  File "C:\Program Files\Python37\lib\site-packages\tensorflow_core\python\keras\saving\__init__.py", line 20, in <module>
    from tensorflow.python.keras.saving.hdf5_format import load_attributes_from_hdf5_group
  File "C:\Program Files\Python37\lib\site-packages\tensorflow_core\python\keras\saving\hdf5_format.py", line 32, in <module>
    from tensorflow.python.keras.utils import conv_utils
  File "C:\Program Files\Python37\lib\site-packages\tensorflow_core\python\keras\utils\__init__.py", line 38, in <module>
    from tensorflow.python.keras.utils.multi_gpu_utils import multi_gpu_model
  File "C:\Program Files\Python37\lib\site-packages\tensorflow_core\python\keras\utils\multi_gpu_utils.py", line 22, in <module>
    from tensorflow.python.keras.engine.training import Model
  File "C:\Program Files\Python37\lib\site-packages\tensorflow_core\python\keras\engine\training.py", line 43, in <module>
    from tensorflow.python.keras import metrics as metrics_module
  File "C:\Program Files\Python37\lib\site-packages\tensorflow_core\python\keras\metrics.py", line 34, in <module>
    from tensorflow.python.keras.engine.base_layer import Layer
ImportError: cannot import name 'Layer' from 'tensorflow.python.keras.engine.base_layer' (C:\Program Files\Python37\lib\site-packages\tensorflow_core\python\keras\engine\base_layer.py)

However, if i run it standalone game, it works perfectly fine from the get go. This really got me scratching my head.

Update for anyone who might stumble upon this issue.

If you disable the AlembicImporter plugin it should work.
Currently trying to figure out another way of doing this.

Works perfectly. I can’t thank you enough. I have spent a lot of time trying to solve this problem but couldn’t figure it out.
For anyone wondering, I’m using UE 4.26