开发者

Yet another python import issue of mine

Looks like I am having a real tough day with python imports.I am using Flask and am trying to organise my app structure.I am using it on GAE and thus have to put python packages in my app itself. It looks something like this below:-

-MyFolder
  -flask
  -werkzeug
  -Myapp
    - __init__.py
    -templates
    -static
    -views.py
  -blinker

As of now I import the blinker library into Myapp's __init__. But I wanted to organise these extra packages like blinker into a helper package so as to look like this.

-helper
 -__init__.py
 -blinker

(blinker's __init__.py file looks like this)

from blinker.base import.....

But when I try importing blinker into Myapp's __init__ using

from helper import blinker

I get an impor开发者_JS百科t error saying no module named blinker.base.Why should that happen. Looks like it looks for a blinker package outside of the current one. Why should it happen?


sys.path.append could also fit your purpose.


Smells like you want to be using a relative import.

from .base import ...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜