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"?
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>')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.