question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Colab fails to find a module when initializing the model

See original GitHub issue

When running the code under the title “Initialize the model”, got this error:

Downloading model bundle. This will take less than a minute...
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-8-877ee4174f89> in <module>()
      4 # Import dependencies.
      5 from magenta.models.melody_rnn import melody_rnn_sequence_generator
----> 6 from magenta.models.shared import sequence_generator_bundle
      7 from magenta.music.protobuf import generator_pb2
      8 from magenta.music.protobuf import music_pb2

/usr/local/lib/python3.6/dist-packages/magenta/models/shared/sequence_generator_bundle.py in <module>()
     15 """Utility functions for handling bundle files."""
     16 
---> 17 from magenta.protobuf import generator_pb2
     18 import tensorflow as tf
     19 from google.protobuf import message

ModuleNotFoundError: No module named 'magenta.protobuf'

---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------

maybe a library version mismatch?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
cghawthornecommented, Apr 1, 2020

Thanks for the report, @opheliagame! The problem ended up being the %tensorflow_version 1.x line, which apparently resets the packages installed and reverts the magenta package to a very old version. If you just move that to the top of the cell, it should start working.

We’ll have a fixed version posted in a couple days.

0reactions
opheliagamecommented, Mar 31, 2020

I am having the same issue in the Making Sounds with Note Sequences section. This error appears in the first step, while installing dependencies.

Building wheel for hdfs (setup.py) ... done
  Building wheel for httplib2 (setup.py) ... done
  Building wheel for oauth2client (setup.py) ... done
  Building wheel for avro-python3 (setup.py) ... done
  Building wheel for google-apitools (setup.py) ... done
  Building wheel for pypng (setup.py) ... done
  Building wheel for bz2file (setup.py) ... done
  Building wheel for grpc-google-iam-v1 (setup.py) ... done
ERROR: pydrive 1.3.1 has requirement oauth2client>=4.0.0, but you'll have oauth2client 3.0.0 which is incompatible.
ERROR: google-api-python-client 1.7.12 has requirement httplib2<1dev,>=0.17.0, but you'll have httplib2 0.12.0 which is incompatible.
ERROR: chainer 6.5.0 has requirement typing<=3.6.6, but you'll have typing 3.7.4.1 which is incompatible.
ERROR: chainer 6.5.0 has requirement typing-extensions<=3.6.6, but you'll have typing-extensions 3.7.4.1 which is incompatible.
ERROR: dm-sonnet 1.36 has requirement tensorflow-probability<0.9.0,>=0.8.0, but you'll have tensorflow-probability 0.7.0 which is incompatible.
Importing libraries and defining some helper functions...
TensorFlow 1.x selected.
WARNING:tensorflow:From /tensorflow-1.15.2/python3.6/magenta/pipelines/statistics.py:131: The name tf.logging.info is deprecated. Please use tf.compat.v1.logging.info instead.

WARNING:tensorflow:From /tensorflow-1.15.2/python3.6/magenta/music/note_sequence_io.py:60: The name tf.python_io.TFRecordWriter is deprecated. Please use tf.io.TFRecordWriter instead.

🎉 Done!
0.3.19
1.15.2

Next step gives

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-2-acbb8b942830> in <module>()
----> 1 from magenta.music.protobuf import music_pb2
      2 
      3 twinkle_twinkle = music_pb2.NoteSequence()
      4 
      5 # Add the notes to the sequence.

ModuleNotFoundError: No module named 'magenta.music.protobuf'

---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------

I have tried factory resetting the runtime, but that doesn’t help.

Read more comments on GitHub >

github_iconTop Results From Across the Web

import import tensorflow_docs error on Colab - Stack Overflow
This error is caused by the dict[str, str] line. This is PEP-585 compliant code that works in Python 3.9, but it looks like...
Read more >
Saving and loading models for inference in PyTorch
Steps · 1. Import necessary libraries for loading our data · 2. Define and intialize the neural network · 3. Initialize the optimizer...
Read more >
Python import: Advanced Techniques and Tips
You'll learn from several code examples throughout. In this tutorial, you'll learn how to: Use modules, packages, and namespace packages; Handle resources and ......
Read more >
Google Colab - neptune.ai documentation
By running your model training in a Colab notebook and keeping track of it ... How do I find my API token? ......
Read more >
PySpark on Google Colab 101 - Towards Data Science
Since it runs on the Google server, we don't need to install anything in our system locally, be it Spark or any deep...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found