ModuleNotFoundError in Chapter 1

I’m in Chapter 1, and (I think) I’ve followed the instructions for setting up my environment. My Python version is 3.10.11. I’m running a local Jupyter notebook (I do not get this error on Google Colab). When I try to execute:

classifier = pipeline("sentiment-analysis")

I get an error that summarizes as follows:

RuntimeError: Failed to import transformers.models.distilbert.modeling_tf_distilbert because of the following error (look up to see its traceback):
No module named 'keras.engine

What should I be looking at to fix this?



pip install tensorflow

Thanks for the response! Unfortunately, this isn’t the issue. Tensorflow is installed (although it was not imported for this chapter at this point). If I do import it, it doesn’t change the error. FWIW, though, the version of TF that is installed is ‘2.13.0-rc1’.

Also, I’m on OS X, Ventura (13.3) M2 Max chip.

maybe try to downgrade your latest tensorflow and keras into lower one! i had same issue with tensorflow the reason was for my os was using cuda 12 and tensorflow not supporting it! i think you may try downgrade :slight_smile:

Thanks for the suggestion. I think that probably this is what I need, but it looks like Apple’s M2 architecture doesn’t really support older versions very well. I’ll keep experimenting. In the meantime, I can work through the course on Colab.

1 Like