i just moved from bottleframework to flask. I changes what needed to be altered to convert the code and when i run it i just get "Internal server error" Running tail -f ../logs/error_log i get no err
i just moved from bottleframework to flask. I changes what needed to be altered to convert the code and when i run it i just get "Internal server error" Running tail -f ../logs/error_log i get no errors. How can i find out what is the culprit here? [nikos@superhost wsgi]$ export FLASK_APP=www.py [nikos@superhost wsgi]$ export FLASK_ENV=development [nikos@superhost wsgi]$ flask run * Serving Flask app 'www.py' (lazy loading) * Environment: development * Debug mode: on Usage: flask run [OPTIONS] Try 'flask run --help' for help. Error: While importing 'www', an ImportError was raised: Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/flask/cli.py", line 256, in locate_app __import__(module_name) File "/home/nikos/wsgi/www.py", line 4, in import counters File "/home/nikos/wsgi/counters.py", line 6, in from flask import run, route, request, redirect ImportError: cannot import name 'run' and this is the error_log when tries to be displayed via browser: [Thu Jul 08 15:08:36.436195 2021] [wsgi:error] [pid 575443:tid 139757752112896] [remote 89.210.199.119:6718] mod_wsgi (pid=575443): Failed to exec Python script file '/home/nikos/wsgi/www.py'. [Thu Jul 08 15:08:36.436276 2021] [wsgi:error] [pid 575443:tid 139757752112896] [remote 89.210.199.119:6718] mod_wsgi (pid=575443): Exception occurred processing WSGI script '/home/nikos/wsgi/www.py'. [Thu Jul 08 15:08:36.436408 2021] [wsgi:error] [pid 575443:tid 139757752112896] [remote 89.210.199.119:6718] Traceback (most recent call last): [Thu Jul 08 15:08:36.436432 2021] [wsgi:error] [pid 575443:tid 139757752112896] [remote 89.210.199.119:6718] File "/home/nikos/wsgi/www.py", line 4, in [Thu Jul 08 15:08:36.436436 2021] [wsgi:error] [pid 575443:tid 139757752112896] [remote 89.210.199.119:6718] import counters [Thu Jul 08 15:08:36.436441 2021] [wsgi:error] [pid 575443:tid 139757752112896] [remote 89.210.199.119:6718] File "/home/nikos/wsgi/counters.py", line 6, in [Thu Jul 08 15:08:36.436444 2021] [wsgi:error] [pid 575443:tid 139757752112896] [remote 89.210.199.119:6718] from flask import run, route, request, redirect [Thu Jul 08 15:08:36.436458 2021] [wsgi:error] [pid 575443:tid 139757752112896] [remote 89.210.199.119:6718] ImportError: cannot import name 'run' [Thu Jul 08 15:08:40.075655 2021] [wsgi:error] [pid 575443:tid 13975291008] [remote 89.210.199.119:13389] mod_wsgi (pid=575443): Failed to exec Python script file '/home/nikos/wsgi/www.py'. [Thu Jul 08 15:08:40.075703 2021] [wsgi:error] [pid 575443:tid 13975291008] [remote 89.210.199.119:13389] mod_wsgi (pid=575443): Exception occurred processing WSGI script '/home/nikos/wsgi/www.py'. [Thu Jul 08 15:08:40.075785 2021] [wsgi:error] [pid 575443:tid 13975291008] [remote 89.210.199.119:13389] Traceback (most recent call last): [Thu Jul 08 15:08:40.075802 2021] [wsgi:error] [pid 575443:tid 13975291008] [remote 89.210.199.119:13389] File "/home/nikos/wsgi/www.py", line 4, in [Thu Jul 08 15:08:40.075805 2021] [wsgi:error] [pid 575443:tid 13975291008] [remote 89.210.199.119:13389] import counters [Thu Jul 08 15:08:40.075810 2021] [wsgi:error] [pid 575443:tid 13975291008] [remote 89.210.199.119:13389] File "/home/nikos/wsgi/counters.py", line 6, in [Thu Jul 08 15:08:40.075813 2021] [wsgi:error] [pid 575443:tid 13975291008] [remote 89.210.199.119:13389] from flask import run, route, request, redirect [Thu Jul 08 15:08:40.075825 2021] [wsgi:error] [pid 575443:tid 13975291008] [remote 89.210.199.119:13389] ImportError: cannot import name 'run' -- https://mail.python.org/mailman/listinfo/python-list
Re: i just moved from bottleframework to flask. I changes what needed to be altered to convert the code and when i run it i just get "Internal server error" Running tail -f ../logs/error_log i get no
Στις Πέμπτη, 8 Ιουλίου 2021 στις 7:16:27 μ.μ. UTC+3, ο χρήστης Stestagg έγραψε: > [my reply on the list this time :)] > > That's fine. Sorry, I should have provided more information. > > This type of error that you're gettting /can/ happen if you have the > library correctly installed, but within your project, you have a different > file of the same name as the library. > Then when python tries to import 'flask', it actually imports your local > file, NOT the installed flask. > > You see the error message is *not* saying that python can't find flask, but > that it can't find a name `run` within the flask module: > from flask import run, route, request, redirect > ImportError: cannot import name 'run' > Therefore python has successfully found a module named flask somewhere, > just that it's probably not the module you were expecting it to find. > > This is almost always because of the file name issue I mentioned above, OR > because the wrong version of flask has been installed, or something similar. > > One thing to try would be at the *very* top of counters.py, add the > following lines: > import flask > print(flask) > > then run your command again, and see what the stdout output is. You should > see something like: > > > > Does XX look like the right place for the flask installation? if not, > then that's the problem. After inserting the lines you told me i get the following when i try to run it via browser [nikos@superhost wsgi]$ tail -f ../logs/error_log [Thu Jul 08 19:22:31.042014 2021] [wsgi:error] [pid 575443:tid 13975291008] [remote 89.210.199.119:4206] ImportError: cannot import name 'run' [Thu Jul 08 19:22:32.723900 2021] [wsgi:error] [pid 575443:tid 139757752112896] [Thu Jul 08 19:22:32.724068 2021] [wsgi:error] [pid 575443:tid 139757752112896] [remote 89.210.199.119:8556] mod_wsgi (pid=575443): Failed to exec Python script file '/home/nikos/wsgi/www.py'. should i try always to run flask via browser or as "flask run" ? os is it the same? -- https://mail.python.org/mailman/listinfo/python-list
Re: i just moved from bottleframework to flask. I changes what needed to be altered to convert the code and when i run it i just get "Internal server error" Running tail -f ../logs/error_log i get no
Στις Πέμπτη, 8 Ιουλίου 2021 στις 7:09:49 μ.μ. UTC+3, ο χρήστης Stestagg έγραψε: > Hi > > Do you have a file or folder named 'flask' in the same directory as www.py > by any chance? No, the way i have installed flask was under root account with the command pip3 install flask. But even if i installed flask under my nikos user account its evene worse as the file flask is not entered into PATH. So i guess as root i have to install flask, but then why cant it import 'run" ? [root@superhost ~]# whereis flask flask: /usr/local/bin/flask -- https://mail.python.org/mailman/listinfo/python-list
Re: i just moved from bottleframework to flask. I changes what needed to be altered to convert the code and when i run it i just get "Internal server error" Running tail -f ../logs/error_log i get no
Στις Πέμπτη, 8 Ιουλίου 2021 στις 7:16:27 μ.μ. UTC+3, ο χρήστης Stestagg έγραψε: > [my reply on the list this time :)] > > That's fine. Sorry, I should have provided more information. > > This type of error that you're gettting /can/ happen if you have the > library correctly installed, but within your project, you have a different > file of the same name as the library. > Then when python tries to import 'flask', it actually imports your local > file, NOT the installed flask. > > You see the error message is *not* saying that python can't find flask, but > that it can't find a name `run` within the flask module: > from flask import run, route, request, redirect > ImportError: cannot import name 'run' > Therefore python has successfully found a module named flask somewhere, > just that it's probably not the module you were expecting it to find. > > This is almost always because of the file name issue I mentioned above, OR > because the wrong version of flask has been installed, or something similar. > > One thing to try would be at the *very* top of counters.py, add the > following lines: > import flask > print(flask) > > then run your command again, and see what the stdout output is. You should > see something like: > > > > Does XX look like the right place for the flask installation? if not, > then that's the problem. > > Steve > > On Thu, Jul 8, 2021 at 5:08 PM Νίκος Βέργος > wrote: > > No, the way i have installed flask was under root account with the command > > pip3 install flask. > > But even if i installed flask under my nikos user account its evene worse > > as the file flask is not entered into PATH. > > > > So i guess as root i have to install flask, but then why cant it import > > 'run" ? > > > > [root@superhost ~]# whereis flask > > flask: /usr/local/bin/flask > > > > Στις Πέμ, 8 Ιουλ 2021 στις 7:02 μ.μ., ο/η Stestagg > > έγραψε: > > > >> Hi > >> > >> Do you have a file or folder named 'flask' in the same directory as > >> www.py by any chance? > >> > >> Steve > >> > >> On Thu, Jul 8, 2021 at 4:50 PM [email protected] < > >> [email protected]> wrote: > >> > >>> i just moved from bottleframework to flask. I changes what needed to be > >>> altered to convert the code and when i run it i just get "Internal server > >>> error" > >>> > >>> Running tail -f ../logs/error_log i get no errors. > >>> > >>> How can i find out what is the culprit here? > >>> > >>> [nikos@superhost wsgi]$ export FLASK_APP=www.py > >>> [nikos@superhost wsgi]$ export FLASK_ENV=development > >>> [nikos@superhost wsgi]$ flask run > >>> * Serving Flask app 'www.py' (lazy loading) > >>> * Environment: development > >>> * Debug mode: on > >>> Usage: flask run [OPTIONS] > >>> Try 'flask run --help' for help. > >>> > >>> Error: While importing 'www', an ImportError was raised: > >>> > >>> Traceback (most recent call last): > >>> File "/usr/local/lib/python3.6/site-packages/flask/cli.py", line > >>> 256, in locate_app > >>> __import__(module_name) > >>> File "/home/nikos/wsgi/www.py", line 4, in > >>> import counters > >>> File "/home/nikos/wsgi/counters.py", line 6, in > >>> from flask import run, route, request, redirect > >>> ImportError: cannot import name 'run' > >>> > >>> and this is the error_log when tries to be displayed via browser: > >>> > >>> [Thu Jul 08 15:08:36.436195 2021] [wsgi:error] [pid 575443:tid > >>> 139757752112896] [remote 89.210.199.119:6718] mod_wsgi (pid=575443): > >>> Failed to exec Python script file '/home/nikos/wsgi/www.py'. > >>> > >>> [Thu Jul 08 15:08:36.436276 2021] [wsgi:error] [pid 575443:tid > >>> 139757752112896] [remote 89.210.199.119:6718] mod_wsgi (pid=575443): > >>> Exception occurred processing WSGI script '/home/nikos/wsgi/www.py'. > >>> > >>> [Thu Jul 08 15:08:36.436408 2021] [wsgi:error] [pid 575443:tid > >>> 139757752112896] [remote 89.210.199.119:6718] Traceback (most recent > >>> call last): > >>> > >>>
Re: i just moved from bottleframework to flask. I changes what needed to be altered to convert the code and when i run it i just get "Internal server error" Running tail -f ../logs/error_log i get no
Στις Παρασκευή, 9 Ιουλίου 2021 στις 12:03:00 π.μ. UTC+3, ο χρήστης Menno Holscher έγραψε: > Op 08-07-2021 om 15:42 schreef [email protected]: > > i just moved from bottleframework to flask. I changes what needed to be > > altered to convert the code and when i run it i just get "Internal server > > error" > This error is the error any web site shows when the code of your > application has an error. > > How can i find out what is the culprit here? > > > > [nikos@superhost wsgi]$ export FLASK_APP=www.py > > [nikos@superhost wsgi]$ export FLASK_ENV=development > > [nikos@superhost wsgi]$ flask run > > * Serving Flask app 'www.py' (lazy loading) > > * Environment: development > > * Debug mode: on > > Usage: flask run [OPTIONS] > > Try 'flask run --help' for help. > > > > Error: While importing 'www', an ImportError was raised: > > > > Traceback (most recent call last): > > File "/usr/local/lib/python3.6/site-packages/flask/cli.py", line 256, in > > locate_app > > __import__(module_name) > > File "/home/nikos/wsgi/www.py", line 4, in > > import counters > > File "/home/nikos/wsgi/counters.py", line 6, in > > from flask import run, route, request, redirect > > ImportError: cannot import name 'run' > > > When I import flask in the REPL (the Python command processor) and look > at what it exports: > > >>> import flask > >>> dir(flask) > ['Blueprint', 'Config', 'Flask', 'Markup', 'Request', 'Response', > 'Session', '__builtins__', '__cached__', '__doc__', '__file__', > '__loader__', '__name__', '__package__', '__path__', '__spec__', > '__version__', '_app_ctx_stack', '_compat', '_request_ctx_stack', > 'abort', 'after_this_request', 'app', 'appcontext_popped', > 'appcontext_pushed', 'appcontext_tearing_down', > 'before_render_template', 'blueprints', 'cli', 'config', > 'copy_current_request_context', 'ctx', 'current_app', 'escape', 'flash', > 'g', 'get_flashed_messages', 'get_template_attribute', 'globals', > 'got_request_exception', 'has_app_context', 'has_request_context', > 'helpers', 'json', 'json_available', 'jsonify', 'make_response', > 'message_flashed', 'redirect', 'render_template', > 'render_template_string', 'request', 'request_finished', > 'request_started', 'request_tearing_down', 'safe_join', 'send_file', > 'send_from_directory', 'session', 'sessions', 'signals', > 'signals_available', 'stream_with_context', 'template_rendered', > 'templating', 'url_for', 'wrappers'] > ... there is no "run" there. What were you trying to achieve? > > If you are thinking about the "flask run" mentioned in startup, that is > a bash/cmd command, an easy way to start the server from the command line: > > (venv):~/python/debtors> export FLASK_APP=debtors ; flask run > * Serving Flask app "debtors" > * Environment: production > WARNING: This is a development server. Do not use it in a production > deployment. > Use a production WSGI server instead. > * Debug mode: off > * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit) > > > -- > Met vriendelijke groet / Kind regards > > Menno Hölscher Now it complains it cannot find the module route. How is that even possible? Do i have something wrong in the www.py? from flask import Flask, route, request, redirect, render_template, url_for, send_from_directory, debug app = Flask(__name__) app.run(debug=True) [nikos@superhost wsgi]$ flask run * Serving Flask app 'www.py' (lazy loading) * Environment: production WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. * Debug mode: off Usage: flask run [OPTIONS] Try 'flask run --help' for help. Error: While importing 'www', an ImportError was raised: Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/flask/cli.py", line 256, in locate_app __import__(module_name) File "/home/nikos/wsgi/www.py", line 4, in import counters File "/home/nikos/wsgi/counters.py", line 9, in from flask import route, request, redirect ImportError: cannot import name 'route' Also i use run for this app.run( host='superhost.gr', port=5000, debug=True ) -- https://mail.python.org/mailman/listinfo/python-list
Re: i just moved from bottleframework to flask. I changes what needed to be altered to convert the code and when i run it i just get "Internal server error" Running tail -f ../logs/error_log i get no
Στις Παρασκευή, 9 Ιουλίου 2021 στις 3:57:11 μ.μ. UTC+3, ο χρήστης Menno Holscher έγραψε: > Op 09-07-2021 om 08:14 schreef [email protected]: > > Στις Παρασκευή, 9 Ιουλίου 2021 στις 12:03:00 π.μ. UTC+3, ο χρήστης Menno > > Holscher έγραψε: > >> Op 08-07-2021 om 15:42 schreef [email protected]: > >>>>> import flask > >>>>> dir(flask) > >> ['Blueprint', 'Config', 'Flask', 'Markup', 'Request', 'Response', > >> 'Session', '__builtins__', '__cached__', '__doc__', '__file__', > >> '__loader__', '__name__', '__package__', '__path__', '__spec__', > >> '__version__', '_app_ctx_stack', '_compat', '_request_ctx_stack', > >> 'abort', 'after_this_request', 'app', 'appcontext_popped', > >> 'appcontext_pushed', 'appcontext_tearing_down', > >> 'before_render_template', 'blueprints', 'cli', 'config', > >> 'copy_current_request_context', 'ctx', 'current_app', 'escape', 'flash', > >> 'g', 'get_flashed_messages', 'get_template_attribute', 'globals', > >> 'got_request_exception', 'has_app_context', 'has_request_context', > >> 'helpers', 'json', 'json_available', 'jsonify', 'make_response', > >> 'message_flashed', 'redirect', 'render_template', > >> 'render_template_string', 'request', 'request_finished', > >> 'request_started', 'request_tearing_down', 'safe_join', 'send_file', > >> 'send_from_directory', 'session', 'sessions', 'signals', > >> 'signals_available', 'stream_with_context', 'template_rendered', > >> 'templating', 'url_for', 'wrappers'] > >> ... there is no "run" there. What were you trying to achieve? > >> > When you look at the exported symbols, there is no route, so if you > expected flask to export route it is not there either. > > How is that even possible? > > > > Do i have something wrong in the www.py? > > > > from flask import Flask, route, request, redirect, render_template, > > url_for, send_from_directory, debug > > > > app = Flask(__name__) > > app.run(debug=True) > There is 2 possibilities here. One is you have a module named route. > Than you do not import it as a name from flask, but as a module. > > The other is you are looking for the attribute route from the Flask class. > > @app.route("/item/", methods=["GET", "POST"]) > > This creates a route. The route method is a method of an instance of > Flask (i.e. app), so importing Flask is enough. > > > > Also i use run for this > > > > app.run( host='superhost.gr', port=5000, debug=True ) > > > Yes, that is OK, if DNS contains a host superhost.gr. > -- > Met vriendelijke groet / Kind regards > > Menno Hölscher please tell me what i need to do to be able to see error messages in browser and not only via console: app = Flask(__name__) app.debug = True application = app The above only displays error via console into the error_log, having to open it each time. how can i see it in browser? -- https://mail.python.org/mailman/listinfo/python-list
Re: i just moved from bottleframework to flask. I changes what needed to be altered to convert the code and when i run it i just get "Internal server error" Running tail -f ../logs/error_log i get no
Στις Παρασκευή, 9 Ιουλίου 2021 στις 4:10:29 μ.μ. UTC+3, ο χρήστης Chris Angelico έγραψε: > On Fri, Jul 9, 2021 at 11:07 PM [email protected] > wrote: > > please tell me what i need to do to be able to see error messages in > > browser and not only via console: > > > > app = Flask(__name__) > > app.debug = True > > application = app > > > > The above only displays error via console into the error_log, having to > > open it each time. how can i see it in browser? > Until you're able to serve pages, you won't get anything in the browser. > > Nikos, you've come back to this list a few times over the years, and > each time, you're trying to host web sites with a very shaky > understanding of what's actually going on. Are you still trying to > provide hosting services to other people, and if so, have you - as was > advised multiple times in the past - dedicated a week to actually > learning how HTTP works and how web browsers and back end apps > communicate? > > ChrisA This is a perosnal project of mine. Iam abl to server the page i want, its just in a specific function i get an error and that error is being displayed on console, and i'am trying to make it seen via browser instead. Isn't app.debug = True enough to do that? eveb if i add app.testing=True i still cant see the errors in the browser. -- https://mail.python.org/mailman/listinfo/python-list
Re: i just moved from bottleframework to flask. I changes what needed to be altered to convert the code and when i run it i just get "Internal server error" Running tail -f ../logs/error_log i get no
Στις Παρασκευή, 9 Ιουλίου 2021 στις 4:10:29 μ.μ. UTC+3, ο χρήστης Chris Angelico έγραψε: > On Fri, Jul 9, 2021 at 11:07 PM [email protected] > wrote: > > please tell me what i need to do to be able to see error messages in > > browser and not only via console: > > > > app = Flask(__name__) > > app.debug = True > > application = app > > > > The above only displays error via console into the error_log, having to > > open it each time. how can i see it in browser? > Until you're able to serve pages, you won't get anything in the browser. > > Nikos, you've come back to this list a few times over the years, and > each time, you're trying to host web sites with a very shaky > understanding of what's actually going on. Are you still trying to > provide hosting services to other people, and if so, have you - as was > advised multiple times in the past - dedicated a week to actually > learning how HTTP works and how web browsers and back end apps > communicate? > > ChrisA from werkzeug.debug import DebuggedApplication app = Flask(__name__) application = app application = DebuggedApplication(app, True) I even tries this solution and i still see errors appear *only* in the error_log. WHY?! -- https://mail.python.org/mailman/listinfo/python-list
Re: i just moved from bottleframework to flask. I changes what needed to be altered to convert the code and when i run it i just get "Internal server error" Running tail -f ../logs/error_log i get no
Στις Παρασκευή, 9 Ιουλίου 2021 στις 11:48:43 μ.μ. UTC+3, ο χρήστης Menno Holscher έγραψε: > Op 09-07-2021 om 15:01 schreef [email protected]: > > please tell me what i need to do to be able to see error messages in > > browser and not only via console: > > > > app = Flask(__name__) > > app.debug = True > > application = app > > > > The above only displays error via console into the error_log, having to > > open it each time. how can i see it in browser? > > > This is totally unrelated to your earlier question, and (as many things > Flask) well documented. > > Look at > https://flask.palletsprojects.com/en/2.0.x/debugging/#the-built-in-debugger > -- > Met vriendelijke groet / Kind regards > > Menno Hölscher i managed to run i with built in debugger by setting export FLASK_ENV=development Every time I start up my flask app the environment variable is set to production. I want to have it set to development mode by default. Otherwise every time I start my app i have to run .. export FLASK_ENV=development How can I set environment's default value as development in every startup? -- https://mail.python.org/mailman/listinfo/python-list
