python - Issue importing object within the same directory -


let's assume have directory structure:

tumblelog/   __init__.py   manage.py 

when try import app __init__.py in manage.py statement:

from tumblelog import app 

i following error:

importerror: no module named tumblelog 

you have import module not directory.

your code has be:

from __init__ import app 

this create pyc file. "from" expression declares file, "import" declares function being imported.

alternatively, if want import functions write

import __init__ 

and write

__init__.app() 

to use it

or import without having retype module time:

from __init__ import * 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -

Why does a .NET 4.0 program produce a system.unauthorizedAccess error on a Windows Server 2012 machine with .NET 4.5 installed? -