Reputation:
I have a structure as
name_folder:
tobeused.py
name_folder:
__init__.py
models.py
radial.py
In module tobeused.py
I did
from name_folder import models
.
In module models.py
I did from radial import rad
(rad
is function in radial.py
)
When I run models.py
directly, it works. But when I run tobeused.py
an error shows :
ImportError: No module named 'radial'
How to work on this? Thanks
Upvotes: 2
Views: 60
Reputation: 5224
add __init__.py
file to your folder
tobeused.py
folder:
__init__.py
models.py
radial.py
Detailed explanation : What is __init__.py for?
The import :
from folder.models import something
Upvotes: 1
Reputation: 377
Change from radial import rad to from .radial import rad
The . allows the file to look locally rather than within the working directory.
Upvotes: 1