0

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'
Sujal Singh
  • 532
  • 1
  • 5
  • 14
Saurhub
  • 1
  • 3

3 Answers3

0

Try changing your import statement in create_data_test.py from:

import opensubtitles.create_data.py

to:

import create_data
Sujal Singh
  • 532
  • 1
  • 5
  • 14
0

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?

  • Even after fixing the typo it won't work – Sujal Singh Jan 04 '22 at 12:24
  • try to import create_data.py without the folder... your python files are in the same folder. import create_data.py – Raphael Amorminio Jan 04 '22 at 12:50
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 04 '22 at 14:18
  • @SujalSingh https://github.com/PolyAI-LDN/conversational-datasets – Saurhub Jan 04 '22 at 18:29
  • @RaphaelAmorminio https://github.com/PolyAI-LDN/conversational-datasets – Saurhub Jan 04 '22 at 18:29
0
from opensubtitles import create_data
from opensubtitles import create_data_test

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.

Anand Gautam
  • 2,018
  • 1
  • 3
  • 8