Skip to content

ModuleNotFoundError: No module named 'keras._tf_keras #30

@michaelbcerny

Description

@michaelbcerny

I enjoyed reading your paper in Political Analysis, and I'm now trying to implement the 'rMIDAS' package in R. I'm encountering a ModuleNotFoundError: No module named 'keras._tf_keras' error when attempting to use TensorFlow and TensorFlow Addons via the reticulate package in R. This issue persists despite setting up a clean Python environment and ensuring that compatible versions of TensorFlow and TensorFlow Addons are installed.

My specifications:

  • Platform: Posit Cloud
  • R version: 4.3.3
  • Python version: 3.11.4
  • TensorFlow version: 2.16.1 (also attempted with 2.15.0)
  • TensorFlow Addons version: 0.20.0

To recreate the error:

  1. Create a new virtual environment using reticulate::virtualenv_create(envname = "rmidas_env", python_version = "3.8")
  2. Install TensorFlow and TensorFlow Addons:
    • reticulate::py_install("tensorflow==2.15.0", envname = "rmidas_env")
    • reticulate::py_install("tensorflow-addons==0.20.0", envname = "rmidas_env")
  3. Attempt to import TensorFlow and TensorFlow Addons in R:
    • reticulate::py_run_string("import tensorflow")
    • reticulate::py_run_string("import tensorflow_addons")

The issue seems related to how TensorFlow Addons interacts with the TensorFlow/Keras integration (adjustments to the versions and reinstallation of packages did not resolve the issue).

Do you have any suggestions?

Thank you for looking into this!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions