neo4j-graphacademy / app-python

https://graphacademy.neo4j.com/courses/app-python
56 stars 92 forks source link

Help, failing on "flask run" #2

Closed nawara72 closed 2 years ago

nawara72 commented 2 years ago

Hi I am a newbie to this world so would really appreciate any help. I get an error when running flask run Is there supposed to be an api.py file? The error i get is (sandbox) PS C:\Users\cv\Downloads\app-python-main> flask run

Error: Could not locate a Flask application. You did not provide the "FLASK_APP" environment variable, and a "wsgi.py" or "app.py" module was not found in the current directory.

Thanks

adam-cowley commented 2 years ago

it looks like there isn't a reference within the command line session. I think Windows requires you to run the set command rather than export. Could you try setting the environment variables within the same command?

FLASK_APP=api FLASK_ENV=development flask run
nawara72 commented 2 years ago

Thanks Adam for your reply. I run set FLASK_APP=api set FLASK_ENV=development flask run

Also tried set FLASK_APP=api ; set FLASK_ENV=development ; flask run

same error

Do i need to run it in a special folder. Other web searches mention api.py, I can't find that file. Not sure what I am doing wrong. I am mainly following instructions on https://graphacademy.neo4j.com/courses/app-python/0-setup/1-setup/

Thanks Nawar

adam-cowley commented 2 years ago

Can you try all in one line, without set or semi-colons?

FLASK_APP=api FLASK_ENV=development flask run
nawara72 commented 2 years ago

Just tried (sandbox) PS C:\Users\cv\Downloads\app-python-main> FLASK_APP=api FLASK_ENV=development flask run

got

FLASK_APP=api : The term 'FLASK_APP=api' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1

nawara72 commented 2 years ago

Just checking if the sandbox folder created in the folder that i downloaded from your github Do i need to cd into the sandbox folder? Thanks

nawara72 commented 2 years ago

Adam, i just figured it out. it works when i run $env:FLASK_APP = "api" $env:FLASK_ENV = "development" Great now i can continous with that course. Thanks again for all your help

adam-cowley commented 2 years ago

Nice, I'm glad you got it working. Was this issue down to the instructions not working in PowerShell?

Liu131452 commented 2 years ago

you only need add FLASK_APP = "api" and FLASK_ENV = "development" in .evn file ,then “ flask run”

adam-cowley commented 2 years ago

Great tip, does that work for all OS?

nawara72 commented 2 years ago

Nice, I'm glad you got it working. Was this issue down to the instructions not working in PowerShell?

Not sure Adam, the powershell instructions didn't work on windows but using $env did. Thanks again for all your help

Liu131452 commented 2 years ago

My way in Windows is ok ,I do not test in other system。

cjacca01 commented 2 years ago

I've tried all of the above and it's not working. Any ideas?

adam-cowley commented 2 years ago

Can you provide some more information, please? What version of python are you using? Which operating system? What have you tried so far?