<@ULVA73B9P> I ran `prefect deploy` in an environm...
# ask-marvin
t
@Marvin I ran
prefect deploy
in an environment that contained
prefect==3.0.2
and got a
ModuleNotFoundError("No module named 'boto3'")
. How can I fix it?
m
The error you're encountering,
ModuleNotFoundError("No module named 'boto3'")
, suggests that your deployment process is trying to use the
boto3
library, which is not installed in your environment. This is likely because your deployment configuration or code references AWS services, which require
boto3
. To resolve this issue, you can install the
boto3
package in your environment using pip:
Copy code
bash
pip install boto3
Alternatively, if you're managing dependencies via a
requirements.txt
file or a
prefect.yaml
configuration, ensure that
boto3
is listed there. For more details on deployment configurations and handling dependencies in Prefect 3.x, you can refer to the Prefect deployment documentation. If you're upgrading from a previous version, you might also want to check the upgrade guide to Prefect 3.0 for any additional steps.
n
more likely you want to install
prefect[aws]
bc you're likely using
prefect-aws
right?
t
No, I'm using vanilla Prefect. I thought that with version 3.x I didn't need to install all packages in the environment on which I run
prefect deploy
.
As context, I'm creating a CI/CD pipeline that runs that for my projects. It's obviously not ideal to have to install all dependencies each time it runs
n
you don't necessarily need to, you just may lose information about your parameter schema because it might be impossible to create it if it refers to deps you don't have, ie your flow signatures might look like
(*args, **kwargs)
fwiw IME
uv
and good project structure alleviates most of this pain. ie use uv's GHA cache and after the first time you barely have to install anything in CI unless your deps change
t
okay, but assuming my parameter schema is not relevant (true in this case, because parameters are native Python types), why am I getting this error?
n
without the stack trace its hard to say
t
Sorry, you're right:
Copy code
prefect --no-prompt deploy -n '*-{SOME_SUFFIX}'

Traceback (most recent call last):
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "{ENTYRYPOINT_FILE.PY}", line 5, in <module>
    import boto3
ModuleNotFoundError: No module named 'boto3'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/prefect/cli/_utilities.py", line 42, in wrapper
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/prefect/cli/_types.py", line 153, in sync_fn
    return asyncio.run(async_fn(*args, **kwargs))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/prefect/cli/deploy.py", line 431, in deploy
    await _run_single_deploy(
  File "/usr/local/lib/python3.12/site-packages/prefect/client/utilities.py", line 103, in with_injected_client
    return await fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/prefect/cli/deploy.py", line 481, in _run_single_deploy
    flow = load_flow_from_entrypoint(deploy_config["entrypoint"])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/prefect/flows.py", line 1719, in load_flow_from_entrypoint
    flow = import_object(entrypoint)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/prefect/utilities/importtools.py", line 205, in import_object
    module = load_script_as_module(script_path)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/prefect/utilities/importtools.py", line 168, in load_script_as_module
    raise ScriptError(user_exc=exc, path=path) from exc
prefect.exceptions.ScriptError: Script at 'src/main.py' encountered an exception: ModuleNotFoundError("No module named 'boto3'")
n
hmm that seems odd
Copy code
» cat sandbox/without_deps.py
import pandas

from prefect import flow


@flow
def my_flow():
    df = pandas.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
    print(df)

» prefect --no-prompt deploy -n without_deps
....works fine...

» python sandbox/without_deps.py
Traceback (most recent call last):
  File "/Users/nate/github.com/prefecthq/prefect/sandbox/without_deps.py", line 1, in <module>
    import pandas
ModuleNotFoundError: No module named 'pandas'
can you: • try on latest prefect? • open an issue if you're still having issues?
t
Will do, and agreed—I've seen this same pipeline work sometimes, fail sometimes, depending on the repo.
Thanks Nate!
n
👍
t
Just in case anyone has the same problem, I opened an issue here
m
same issue.
t
It might be useful to comment in the GitHub issue so the devs know I'm not the only one facing this