Importing Modules From Different Directories
I have a problem importing a module: It is under this directory ./dao and the code that calls it is here ./core. Schematically represented as: rnaspace/ __init__.py core/ __in
Solution 1:
from rnaspace.dao.storage_configuration_reader import storage_configuration_reader
That is wrong because there is no "storage_configuration_reader" directory in "dao" directory
This is how it should be:
from rnaspace.dao import storage_configuration_reader
EDIT:
or this way:
import rnaspace.dao.storage_configuration_reader
Solution 2:
I finally found the solution in another question, it is using the module imp.
I just needed to add the name of the module, and the absolute path where it was:
imp.load_source("storage_configuration_reader","./rnaspace/dao/storage_configuration_reader.py")
Post a Comment for "Importing Modules From Different Directories"