Hi all, I think I'm doing something simple and mis...
# data-tricks-and-tips
y
Hi all, I think I'm doing something simple and mistaken. I'm using Python 3.9.6 on Windows 10, and Prefect version 2.8.4, I have the simplest code in a file called dev.py from the 1st tutorial example from the site. I'm using a Python venv too
Copy code
from prefect import flow

@flow
def my_favorite_function():
    print("What is your favorite number?")
    return 42

print(my_favorite_function())
And when I run
python dev.py
it gives me an error
RuntimeError: Cannot create flow run. Failed to reach API at <http://127.0.0.1:4200/api/>
I tried changing the code to:
Copy code
from prefect import flow

@flow
def my_favorite_function():
    print("What is your favorite number?")
    return 42

if __name__ == "__main__":
    print(my_favorite_function())
And it still gives me the same error. Am I missing something? I'm sure I've run this code before when trying to learn
k
do you have the prefect server running?
j
Once you've created a prefect server, it seems the server must always be running, even if you are just running from the command line and not through a deployment.
y
Yeah sorry it wasn't running. I was stepping through the Get Started docs. It has flow code examples without any explicit mention of prefect server until much later. Similarly it asks you to apply a deployment before starting an agent.