1

I am trying to import a Python class from another file but it is not working. I've tried everything posted on relative imports but it is still not working.

My folder hierarchy is as follows:

hierarchy

I need to access the class Victim in victim.py file from test_db_debug.py file.

victim.py

class Victim:
    def __init__():
       ...

test_db_debug.py

import sqlite3
import sys
from code.victim import Victim

When i run the code, i get the error: ModuleNotFoundError: No Module names 'code.victim'; 'code' is not a package.

Can someone please help ?

davidism
  • 121,510
  • 29
  • 395
  • 339
Mervin Hemaraju
  • 1,921
  • 2
  • 22
  • 71

1 Answers1

2

I think it's about naming conflict.

Try to rename "code" to something else.

Check: https://stackoverflow.com/a/36066463/479933

acala
  • 332
  • 3
  • 11