Forums

I chose Python 3.3 web app configuration, but clicking "Save & Run" launches Python 2.7

Why does this happen?

"Save and run" is designed to run something in a console -- it's not related to web apps. Could you give a bit more detail on what you're trying to do?

In my Flask app's main "flask_app.py" file, I defined a universal function (outside the scope of any "app.route()" URL). I had a bug in my definition that was causing my whole server to return an "Unhandled Exception".

I was hoping that by clicking "Save & Run", the console would be able to give me more detail about my error as it tried to parse the function's definition. But the console returned an ImportError (since I was using Python 3's "urllib" module, which is incompatible with 2.7) and never got any further.

I guess I was just hoping that if the console launched in Python 3, it would help me with some troubleshooting and testing.

You could try putting:

#!/usr/local/bin/python3.3

as the first line in the file, or just open a Bash shell, 'cd' to the directory and run it there, e.g.

python3.3 fred.py

HTH Jim

edit by admin so the important # wasn't removed by markdown ;)

I knew I could go the Bash route as you described. But I definitely like your other suggestion as that seems to do exactly what I want. Thanks!!!

Thanks, jgmdavies -- as always you know how to use PythonAnywhere better than we do ;-)

I wish!

Thanks for the edit - of course I hadn't noticed...

Jim