'ValueError and ImportError inside package directory when import variable from init file
I have a directory application in which I have two files. init.py and routes.py. I have set a variable in init.py. while I am one directory below package directory application , I am able to import the variable.
>>> from application import hello_api_blueprint
>>> hello_api_blueprint
<flask.blueprints.Blueprint object at 0x7f4d6869da10>
But when I am inside package directory - application I am not able to import with multiple way
>>> from application import hello_api_blueprint
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named application
>>> from . import hello_api_blueprint
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: Attempted relative import in non-package
How can I import this variable when I am inside the directory.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
