0

I'm working on a project and I'm facing this issue.

i wanted to make an import from some folder but it always throws an exception. here is my files structure:

    \myWebsite
              \childWebsite
                           \importedClass
               \myWebsite(same name as the parent)
                            \classThatCallsTheImportedClass

so my call is as following:

    from myWebsite.childWebsite.importedClass import someFunction

However, it always throws an error: "No module named 'myWebsite.childWebsite'"

I discovered that when executing the call line, django checks the files inside the child "myWebsite" folder and hence it can't find the "importedClass". So, how i make it checks the parent "myWebsite"?

1 Answers1

0

Python error "ImportError: No module named"

I think you ll find an answer here. I posted it here since i cannot comment.

also you maybe need to check if PYTHONPATH is configured correctly. you can use this way to configure the PATH:

   export PYTHONPATH=$PYTHONPATH:`pwd`  (OR your project root directory)

   or 
   import sys
   sys.path.insert(0,'<project directory>') OR
   sys.path.append('<project directory>')
basilisk
  • 1,156
  • 1
  • 14
  • 34