1

Im going through the Microblog tutorial for Flask designed by Miguel.

I made it to part 4 without any issues. Everything ran in the end of part 4.

I started having issues in part 5. After a couple of tries and trying to troubleshoot with the comments in the page, I was not able to finish the exercise.

Thinking it was me, I deleted all of my project and replaced them with the zip downloadable in the page for the exercise. I still get the same error, so the problem is not the code itself.

I get the following error when running views.py:

Link to image on imgur (couldn't post it here due to not having enough reputation)

Here are the libraries I have installed:

Link to image on imgur (couldn't post it here due to not having enough reputation)

My setup:

  • I am using Pycharm to run the files. This machine runs Windows and I found that Pycharm is the most efficient way to run things without dealing with issues with the cmd line.
  • Python 3.4
  • virtualenv created by Pycharm
  • the code can be found on github: github.com/pdgonzalez872/microblog

Potential cause of the problem:

  • The problem may be with the path that I have set up (but why did it work until part 4?)
  • The code itself (maybe something was updated in flask/other libraries since the post?)
Deduplicator
  • 44,692
  • 7
  • 66
  • 118
  • 1
    Rather than pasting an image of the error text, try copy-pasting the error text itself. 1) you don't need rep to do that, and 2) it makes it much easier for the rest of us to read it. – Robᵩ Apr 09 '15 at 14:16
  • will do that from now on @Robᵩ, thanks – pdgonzalez872 Apr 09 '15 at 14:27

1 Answers1

3

views.py isn't meant to be launched separately, there is run.py file to start the project.

Also, it uses relative imports (those with dots before module names), which don't work when you use them in a script passed to the interpreter and used as main. Sorry, I can't explain it well, but maybe you will be interested in those links:

https://docs.python.org/2/tutorial/modules.html#intra-package-references

How to do relative imports in Python?

Community
  • 1
  • 1
Anton Melnikov
  • 1,048
  • 7
  • 21
  • so views.py could fail when running by itself but it may not cause the whole app to fail? Interesting! The reason I ran the scripts separately was to see if there were any syntax issues (I typed the code instead of copy/paste). They always worked, except the views.py - Will continue to try it out! Thank you. (I can't upvote you due to lack of reputation... I would though!) – pdgonzalez872 Apr 09 '15 at 13:50
  • @pdgonzalez782, you are welcome. Also, if you are using Pycharm, it shoud highlight all syntax errors for you. – Anton Melnikov Apr 09 '15 at 15:25