Tomás Rossetti
01/23/2025, 4:20 PMprefect deploy
in an environment that contained prefect==3.0.2
and got a ModuleNotFoundError("No module named 'boto3'")
. How can I fix it?Marvin
01/23/2025, 4:20 PMModuleNotFoundError("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:
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.Nate
01/23/2025, 4:22 PMprefect[aws]
bc you're likely using prefect-aws
right?Tomás Rossetti
01/23/2025, 4:22 PMprefect deploy
.Tomás Rossetti
01/23/2025, 4:23 PMNate
01/23/2025, 4:25 PM(*args, **kwargs)
Nate
01/23/2025, 4:26 PMuv
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 changeTomás Rossetti
01/23/2025, 4:32 PMNate
01/23/2025, 4:32 PMTomás Rossetti
01/23/2025, 4:34 PMprefect --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'")
Nate
01/23/2025, 4:45 PM» 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'
Nate
01/23/2025, 4:46 PMTomás Rossetti
01/23/2025, 4:46 PMTomás Rossetti
01/23/2025, 4:46 PMNate
01/23/2025, 4:46 PMTomás Rossetti
01/25/2025, 12:17 AMmarqeu
02/10/2025, 2:24 AMTomás Rossetti
02/10/2025, 2:04 PM