0

I am trying to import a file in python

my directory structure is

maindir
    __init__.py
    constants.py

    subdirectory
          __init__.py
          code.py

I am trying to import constants in the code file

import sys
sys.path.append('/home/ching/maindir')
from maindir import constants

even after that I am getting this error

ImportError: No module named maindir

Any one got any idea whats wrong?

0

1 Answer 1

5

Try this:

import sys
sys.path.append('/home/ching')
from maindir import constants
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.