0

I have organized Python files in differnt folders:

root_dir
  utils/
    some_file.py
  models.py

In some_file.py I just did this:

import models

But this is not working. I also updated some_file.py with:

file_dir = os.path.dirname(__file__)
sys.path.append(file_dir)

import models

Still i get:

import models
ModuleNotFoundError: No module named 'models'
Exploring
  • 2,493
  • 11
  • 56
  • 97

1 Answers1

1

Try to import it as follows from within the some_file.py:

import sys
sys.path.append('..')
import models

# Use as follows:

# models.function()

Altaf Shaikh
  • 272
  • 1
  • 6