<@ULVA73B9P> I'm running `prefect server start` lo...
# ask-marvin
p
@Marvin I'm running
prefect server start
locally and then also serving a basic flow. I'm running into the error
No module named prefect.engine
. I'm assuming I have a misconfiguration in my environment. Running
prefect --version
yields version 3.4.18
m
thought for 142.6 seconds
Thanks for the details. In Prefect 3.x there is no
prefect.engine
module — that was part of older Prefect internals. The error means something (your code or a dependency) is trying to import
prefect.engine
, which will fail on 3.4.18. Common causes and fixes: - You (or a library) have a 2.x-era import like
import prefect.engine
or
from prefect.engine...
. Remove or update these — user code in 3.x should not import engine internals. - Mixing environments (e.g., running
prefect server start
with one interpreter and running your flow with another) so the wrong set of packages is being used. - Old Prefect 2.x “collections” (prefect-aws, prefect-docker, etc.) still installed. In Prefect 3.x these moved into extras; older packages can import old paths. Quick checks 1) Verify what Prefect you’re importing when your script runs:
Copy code
python -c "import prefect, sys; print(prefect.__version__, prefect.__file__, sys.executable)"
2) Make sure your flow code doesn’t import engine internals. A minimal working example in 3.x:
Copy code
from prefect import flow, task, get_run_logger

@task
def say_hi(name: str):
    logger = get_run_logger()
    <http://logger.info|logger.info>(f"Hi, {name}!")

@flow
def my_flow():
    say_hi("world")

if __name__ == "__main__":
    my_flow.serve(name="demo")  # or my_flow()
3) Check for old packages and upgrade/uninstall as needed:
Copy code
pip freeze | grep -i prefect
# If you see prefect-aws / prefect-docker / prefect-kubernetes, uninstall them:
pip uninstall -y prefect-aws prefect-docker prefect-kubernetes

# Ensure Prefect 3 is current
pip install -U "prefect>=3.4,<4"

# If you need integrations, install extras (example):
pip install -U "prefect[aws]" "prefect[docker]" "prefect[kubernetes]"
4) Make sure there’s no local shadowing: - No file/folder named
prefect
in your project. - Run
which prefect
(or
where prefect
on Windows) and confirm it’s from the same environment you use to run your script. If the error persists, could you paste the full traceback? That will show exactly which import is trying to load
prefect.engine
and we can pinpoint the source. References: - Prefect 3.x docs - Prefect 3 GA announcement
p
Ah - thank you! I did accidentally name a folder
prefect
so that was probably messing with the import!