A
A
axelvagabund2015-06-11 18:02:49
Flask
axelvagabund, 2015-06-11 18:02:49

Can't see the file in the flask project, why?

It does not see the imported file, although the file itself is there, and the function also seems to be without errors, the import is registered in __init__.py
The code itself (github)

The error itself:

(env)
  ➜  flaskblog  python runserver.py
Traceback (most recent call last):
  File "runserver.py", line 1, in <module>
    from flaskblog import app
  File "/home/vagabund/web/flaskblog/flaskblog/__init__.py", line 4, in <module>
    from helper import url_for_other_page
ImportError: No module named 'helper'

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yaroslav, 2015-06-18
@iquantii

At one time there were similar problems - it is necessary to correctly understand the structure of the project and the assignment of "__init__" files.
For myself, I found a solution in studying ready-made templates for new projects, "skeletons" - this allowed me to better understand the importance of the correct organization of the project's file structure, which eliminated the errors described in the question.
I recommend looking at the following projects:
It won't be redundant.
Regarding the question, there is no error after deploying the project, I see this in the browser:
There were suspicions about the loading order of modules (and “dirty” __init__), which is why I suggested studying this issue in more detail.

R
REDkiy, 2016-04-14
@REDkiy

Sometimes it may be necessary to clean up a project from compiled *.pyc files. I don't know why.
Based on the previous answer, this should help.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question