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 her

vergos....@gmail.com vergos.nikolas at gmail.com
Thu Jul 8 13:07:17 EDT 2021


Στις Πέμπτη, 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: 
> 
> <module 'flask' from 'XXXXXXXXX'> 
> 
> Does XXXXXX 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 Νίκος Βέργος <vergos.... at gmail.com> 
> 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 at superhost ~]# whereis flask 
> > flask: /usr/local/bin/flask 
> >
> > Στις Πέμ, 8 Ιουλ 2021 στις 7:02 μ.μ., ο/η Stestagg <stes... at gmail.com>
> > έγραψε: 
> > 
> >> 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 vergos.... at gmail.com < 
> >> vergos.... at gmail.com> 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 at superhost wsgi]$ export FLASK_APP=www.py 
> >>> [nikos at superhost wsgi]$ export FLASK_ENV=development 
> >>> [nikos at 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 <module> 
> >>> import counters 
> >>> File "/home/nikos/wsgi/counters.py", line 6, in <module> 
> >>> 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 <module> 
> >>> 
> >>> [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 <module> 
> >>> 
> >>> [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 
> >>> 139757777291008] [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 
> >>> 139757777291008] [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 
> >>> 139757777291008] [remote 89.210.199.119:13389] Traceback (most recent 
> >>> call last): 
> >>> 
> >>> [Thu Jul 08 15:08:40.075802 2021] [wsgi:error] [pid 575443:tid 
> >>> 139757777291008] [remote 89.210.199.119:13389] File 
> >>> "/home/nikos/wsgi/www.py", line 4, in <module> 
> >>> 
> >>> [Thu Jul 08 15:08:40.075805 2021] [wsgi:error] [pid 575443:tid 
> >>> 139757777291008] [remote 89.210.199.119:13389] import counters 
> >>> 
> >>> [Thu Jul 08 15:08:40.075810 2021] [wsgi:error] [pid 575443:tid 
> >>> 139757777291008] [remote 89.210.199.119:13389] File 
> >>> "/home/nikos/wsgi/counters.py", line 6, in <module> 
> >>> 
> >>> [Thu Jul 08 15:08:40.075813 2021] [wsgi:error] [pid 575443:tid 
> >>> 139757777291008] [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 
> >>> 139757777291008] [remote 89.210.199.119:13389] ImportError: cannot 
> >>> import name 'run'
> >>> -- 
> >>> https://mail.python.org/mailman/listinfo/python-list 
> >>> 
> >>
[nikos at superhost wsgi]$ flask run
 * Serving Flask app 'www.py' (lazy loading)
 * Environment: DEVELOPMENT
 * Debug mode: off
<module 'flask' from '/usr/local/lib/python3.6/site-packages/flask/__init__.py'>
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 <module>
    import counters
  File "/home/nikos/wsgi/counters.py", line 9, in <module>
    from flask import run, route, request, redirect
ImportError: cannot import name 'run'

What can you undestand out this that?

  File "/usr/local/lib/python3.6/site-packages/flask/cli.py", line 256, in locate_app
    __import__(module_name)


More information about the Python-list mailing list