Flask example not working in PyCharm

329 views
Skip to first unread message

Lohrii Alo

unread,
Nov 20, 2016, 1:21:42 AM11/20/16
to PythonForFacebook
I wanted to try out the flask example but looks like the project/directory structure is not designed for PyCharm, please help. Would be very helpful if the documentation has instructions on how to use :-)

I'm getting this error:
C:\Python3.4\python.exe C:/Users/username/PycharmProjects/facebook-login-flask/run.py
Traceback (most recent call last):
  File "C:/Users/username/PycharmProjects/facebook-login-flask/run.py", line 4, in <module>
    from app import app, db
  File "C:\Users\username\PycharmProjects\facebook-login-flask\app\__init__.py", line 8, in <module>
    from app import views, models
  File "C:\Users\username\PycharmProjects\facebook-login-flask\app\views.py", line 5, in <module>
    from models import User
ImportError: No module named 'models'


Martey Dodoo

unread,
Nov 20, 2016, 2:06:22 AM11/20/16
to pythonfo...@googlegroups.com
Since the Flask example should run fine from command line Python (running "C:\Python3.4\python.exe C:/Users/username/PycharmProjects/facebook-login-flask/run.py" outside of PyCharm should work fine), the problem is probably with your PyCharm project structure (as opposed to the Flask example's). Can you check your Project Structure dialog and make sure that your app folder is marked as a source? If this doesn't solve the problem, please reply with a screenshot of the Project Structure dialog.

--
You received this message because you are subscribed to the Google Groups "PythonForFacebook" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pythonforfacebook+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Lohrii Alo

unread,
Nov 20, 2016, 3:07:43 AM11/20/16
to PythonForFacebook
Same error from the command line outside of pycharm too, here's my pycharm project structure

To unsubscribe from this group and stop receiving emails from it, send an email to pythonforfaceb...@googlegroups.com.

Martey Dodoo

unread,
Nov 20, 2016, 12:19:34 PM11/20/16
to pythonfo...@googlegroups.com
Since the screenshot you posted is of the general PyCharm interface and not the Project Structure Dialog in particular, I am not sure whether your app folder is marked as a source. Can you confirm that this is the case?

Since the Flask example directory is not going to be in your PYTHONPATH, you need to run it from the Flask example's directory if you want to run it from the commandline:
cd C:/Users/username/PycharmProjects/facebook-login-flask/
C:\Python3.4\python.exe run.py
 
 

To unsubscribe from this group and stop receiving emails from it, send an email to pythonforfacebook+unsubscribe@googlegroups.com.

Lohrii Alo

unread,
Nov 20, 2016, 1:59:15 PM11/20/16
to PythonForFacebook

Marked the project directory as source in pycharm, that didn't help either.

Attaching two more screenshots which shows the directory structure. I downloaded the example straight from github and did not change any directory structure. As you can see from the commandline screenshot, i'm running from within the project folder with python in my environment PATH

Thanks!

Martey Dodoo

unread,
Nov 20, 2016, 3:18:43 PM11/20/16
to pythonfo...@googlegroups.com
The current Flask example is incompatible with Python 3. If you are able to switch to Python 2, you should be able to install the dependencies from the requirements file and you won't get this error.

To unsubscribe from this group and stop receiving emails from it, send an email to pythonforfacebook+unsubscribe@googlegroups.com.

Lohrii Alo

unread,
Nov 21, 2016, 7:39:18 AM11/21/16
to PythonForFacebook
Thanks for your help Martey!

I was able to get it to run with python 2.7 but ran into a different error now, not sure where the problem is now

Reply all
Reply to author
Forward
0 new messages