0

I'm trying to run this python code in Google Colab and I always get this error that the utils module is not installed or does not exist yet I've ran !pip install utils and the still the same issue. I've tried running it on my computer and it works without issues but I can't actually run it due to limited resources of my pc.

anyway anyone has a solution for this ?

Traceback (most recent call last):
  File "/content/GNN-for-text-classification/preprocess/build_graph.py", line 15, in <module>
    from utils.utils import loadWord2Vec, clean_str
ModuleNotFoundError: No module named 'utils.utils'
Ramy Abidi
  • 1
  • 1
  • 5

1 Answers1

0

I am assuming you are using this GNN-for-Text-Classification.

Now, you have probably cloned the repository in your local system and you're running the .py files from there.

But, a New Notebook in Colab will not have the files that you have cloned/downloaded. So, when you're doing

!pip install utils

The utils package from Pypi is getting installed which doesn't contain the functions you require.

What you need is actually the utils module from GNN-for-Text-Classification, for which you'll need to clone and cd into the folder in Colab itself. Just run the following in your Colab Notebook:

!git clone https://github.com/zshicode/GNN-for-text-classification.git
%cd GNN-for-text-classification/
%ls

This will clone the repo, cd into the folder and view the contents where you will be able to find the utils module that you need.

Now you can import stuff like loadWord2Vec, clean_str without any errors.

Note that this cloning is not permanent since a new Colab instance will not keep the changes from the old one.

indrapaul824
  • 101
  • 2
  • 5
  • Thank you for your answer. I've already used to git clone the files to colab but when I run it I always have the same error and apparently I need to "cd" to the file path and run it for it to work, usually I do !python "full file path" which I copy from context menu when right clicking a file – Ramy Abidi Jul 19 '22 at 19:06
  • I also got this error `tcmalloc: large alloc 1342185472 bytes == 0x82e70000 @ 0x7f228ebf11e7 0x4a3940 0x560b86 0x561b9e 0x512724 0x549576 0x604173 0x5f5506 0x5f8c6c 0x5f9206 0x64faf2 0x64fc4e 0x7f228e7eec87 0x5b621a ` which I don't understand – Ramy Abidi Jul 19 '22 at 19:09
  • [Check this out](https://stackoverflow.com/questions/52351611/is-tcmalloc-large-alloc-a-warning-or-error-in-python) for a detailed understanding of why it happens. Basically, you got this message because it's using up all of the Colab memory. – indrapaul824 Jul 20 '22 at 03:07
  • I'm not sure what is causing this, I'm using a small dataset and I've set embedding size to 5 and I can't figure out what is causing it – Ramy Abidi Jul 20 '22 at 09:49