Home > front end >  module not found Error: Cannot resolve module 'opensubtitles'
module not found Error: Cannot resolve module 'opensubtitles'

Time:01-04

I did everything to resolve this issue. I am a beginner with python. My Folder structure:

├─conversational-datasets-master-opensubtitles/ 
└── conversational-datasets-master/ 
└── opensubtitles/
  └── create_data.py
  └── create_data_test.py
  • in opensubtitles folder, I have two files
  • The first one is create_data.py which is for the train
  • the second one is create_data_test.py which is for testing

So the Question is Whenever I am trying to run the create_data_test.py it shows this error (module not found error)

File "C:\Users\suppo\Desktop\conversational-datasets-master-opensubtitles\conversational-datasets-master\opensubtitles\create_data_test.py", line 15, in <module>
    import opensubtiles.create_data.py
ModuleNotFoundError: No module named 'opensubtiles'

CodePudding user response:

Try changing your import statement in create_data_test.py from:

import opensubtitles.create_data.py

to:

import create_data

CodePudding user response:

I think you just got a typo here ...

import opensubti t les.create_data.py

There are several posts of importing modules and classes in python. Take a look here... hope it helps

How to import the class within the same directory or sub directory?

CodePudding user response:

from opensubtitles import create_data.py
from opensubtitles import create_data_test.py

This should work. But if you are in the root folder, you may have to use joinpath, since there are hyphens in the folder names.

  •  Tags:  
  • Related