Forums

how to print in console

Hi, I am a pythonanywhere newbie. I hosted my first django project on pythonanywhere. The app runs fine locally but it is giving some strange errors when i run it on pythonanywhere. I want to debug it using print statements in my views. How can I see the result of those print statements?

A print in Django will just go to your server log.

Hi I don't notice any 'print()' statements being showed on any 3 of the logs. Do they need to be written differently for PA? e.g. sys.print?

No, just a regular print statement should work fine -- the output will go to the server log. Perhaps flush the standard output after printing, and see if that helps? For example, in Python 3:

print("Logging message", flush=True)

...or in Python 2:

import sys

...

print "Logging message"
sys.stdout.flush()

This does not seem to work using Flask. How can i view flask print statements?

Could you share more details about how you are doing it? You can email us at support@pythonanywherele.com if you do not want to publish it on public forums.