I'm trying to set up a prefect server service from...
# prefect-community
I'm trying to set up a prefect server service from a virtual environment with
ExecStart=/home/ubuntu/apps/dataflows/venv/bin/prefect server start --host
Receiving the following error. Anyone ever see this and/or knows how to fix this?
Copy code
File "/home/ubuntu/.pyenv/versions/3.11.2/lib/python3.11/asyncio/base_subprocess.py", line 36, in __init__
    self._start(args=args, shell=shell, stdin=stdin, stdout=stdout,
  File "/home/ubuntu/.pyenv/versions/3.11.2/lib/python3.11/asyncio/unix_events.py", line 810, in _start
    self._proc = subprocess.Popen(
  File "/home/ubuntu/.pyenv/versions/3.11.2/lib/python3.11/subprocess.py", line 1024, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/home/ubuntu/.pyenv/versions/3.11.2/lib/python3.11/subprocess.py", line 1901, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'uvicorn'
āœ… 1
When you call
prefect server start
we start uvicorn in a subprocess https://github.com/PrefectHQ/prefect/blob/main/src/prefect/cli/server.py#L147-L160
Sounds like uvicorn is not available on the path
hhm, it starts fine on the command line after I start up the virtual environment. Is there some environment/variable that needs to be set?
this is what I see when I try to install the package:
Copy code
(venv) ubuntu@gbi-tableau-innovation:~/apps/dataflows$ pip install uvicorn
Requirement already satisfied: uvicorn in ./venv/lib/python3.11/site-packages (0.20.0)
Requirement already satisfied: click>=7.0 in ./venv/lib/python3.11/site-packages (from uvicorn) (8.1.3)
Requirement already satisfied: h11>=0.8 in ./venv/lib/python3.11/site-packages (from uvicorn) (0.14.0)
It looks like you are calling `prefect `directly from the venv bin
Instead of activating the environment then calling Prefect
So nothing else from the venv will be on the path
Iā€™d take a look at the contents of
yeah, that's sort of the recommendation for running daemons in virtual environments based on what I've read, but makes sense and thanks for the direction. I'll see if there's something I can do on the systemd side, else just wrap the whole thing in a script that starts the virtual environment before running the server
Yup, looks like there's an Environment variable I can set in the service script:
Copy code
Working now, thanks for your help @Zanie!
šŸ™Œ 1