developer
developer copied to clipboard
modal: fix ImportError: Need the `dotenv` package installed.
Maybe Modal has changed their setup or something, but I had this error:
➜ developer git:(main) modal run main.py --prompt prompt.md --model=gpt-4
✓ Initialized. View app at https://modal.com/apps/ap-4ekAxLToNNvhjqJdFjtcH8
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /opt/homebrew/bin/modal:8 in <module> │
│ │
│ 7 │ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) │
│ ❱ 8 │ sys.exit(main()) │
│ 9 │
│ │
│ /opt/homebrew/lib/python3.10/site-packages/modal/__main__.py:6 in main │
│ │
│ 5 def main(): │
│ ❱ 6 │ entrypoint_cli() │
│ 7 │
│ │
│ /opt/homebrew/lib/python3.10/site-packages/click/core.py:1130 in __call__ │
│ │
│ 1129 │ │ """Alias for :meth:`main`.""" │
│ ❱ 1130 │ │ return self.main(*args, **kwargs) │
│ 1131 │
│ │
│ /opt/homebrew/lib/python3.10/site-packages/typer/core.py:778 in main │
│ │
│ 777 │ ) -> Any: │
│ ❱ 778 │ │ return _main( │
│ 779 │ │ │ self, │
│ │
│ /opt/homebrew/lib/python3.10/site-packages/typer/core.py:216 in _main │
│ │
│ 215 │ │ │ with self.make_context(prog_name, args, **extra) as ctx: │
│ ❱ 216 │ │ │ │ rv = self.invoke(ctx) │
│ 217 │ │ │ │ if not standalone_mode: │
│ │
│ /opt/homebrew/lib/python3.10/site-packages/click/core.py:1657 in invoke │
│ │
│ 1656 │ │ │ │ with sub_ctx: │
│ ❱ 1657 │ │ │ │ │ return _process_result(sub_ctx.command.invoke(sub_ctx)) │
│ 1658 │
│ │
│ /opt/homebrew/lib/python3.10/site-packages/click/core.py:1657 in invoke │
│ │
│ 1656 │ │ │ │ with sub_ctx: │
│ ❱ 1657 │ │ │ │ │ return _process_result(sub_ctx.command.invoke(sub_ctx)) │
│ 1658 │
│ │
│ /opt/homebrew/lib/python3.10/site-packages/click/core.py:1404 in invoke │
│ │
│ 1403 │ │ if self.callback is not None: │
│ ❱ 1404 │ │ │ return ctx.invoke(self.callback, **ctx.params) │
│ 1405 │
│ │
│ /opt/homebrew/lib/python3.10/site-packages/click/core.py:760 in invoke │
│ │
│ 759 │ │ │ with ctx: │
│ ❱ 760 │ │ │ │ return __callback(*args, **kwargs) │
│ 761 │
│ │
│ /opt/homebrew/lib/python3.10/site-packages/click/decorators.py:26 in new_func │
│ │
│ 25 │ def new_func(*args, **kwargs): # type: ignore │
│ ❱ 26 │ │ return f(get_current_context(), *args, **kwargs) │
│ 27 │
│ │
│ /opt/homebrew/lib/python3.10/site-packages/modal/cli/run.py:112 in f │
│ │
│ 111 │ │ │
│ ❱ 112 │ │ with run_stub(blocking_stub, detach=ctx.obj["detach"], show_progress=ctx.obj["sh │
│ 113 │ │ │ if isasync: │
│ │
│ /opt/homebrew/lib/python3.10/site-packages/synchronicity/synchronizer.py:497 in proxy_method │
│ │
│ /opt/homebrew/lib/python3.10/site-packages/synchronicity/combined_types.py:26 in __call__ │
│ │
│ /opt/homebrew/Cellar/[email protected]/3.10.11/Frameworks/Python.framework/Versions/3.10/lib/python3.1 │
│ 0/contextlib.py:199 in __aenter__ │
│ │
│ 198 │ │ try: │
│ ❱ 199 │ │ │ return await anext(self.gen) │
│ 200 │ │ except StopAsyncIteration: │
│ │
│ /opt/homebrew/lib/python3.10/site-packages/modal/runner.py:64 in _run_stub │
│ │
│ 63 │ │ │ # Create all members │
│ ❱ 64 │ │ │ await app._create_all_objects(stub._blueprint, output_mgr, post_init_state) │
│ 65 │
│ │
│ /opt/homebrew/lib/python3.10/site-packages/modal/app.py:100 in _create_all_objects │
│ │
│ 99 │ │ │ │ existing_object_id = self._tag_to_existing_id.get(tag) │
│ ❱ 100 │ │ │ │ created_obj = await resolver.load(provider, existing_object_id) │
│ 101 │ │ │ │ self._tag_to_object[tag] = created_obj │
│ │
│ /opt/homebrew/lib/python3.10/site-packages/modal/_resolver.py:81 in load │
│ │
│ 80 │ │ │
│ ❱ 81 │ │ created_obj = await obj._load(self, existing_object_id) │
│ 82 │
│ │
│ /opt/homebrew/lib/python3.10/site-packages/modal/functions.py:976 in _load │
│ │
│ 975 │ │ │ for secret in secrets: │
│ ❱ 976 │ │ │ │ secret_id = (await resolver.load(secret)).object_id │
│ 977 │ │ │ │ secret_ids.append(secret_id) │
│ │
│ /opt/homebrew/lib/python3.10/site-packages/modal/_resolver.py:81 in load │
│ │
│ 80 │ │ │
│ ❱ 81 │ │ created_obj = await obj._load(self, existing_object_id) │
│ 82 │
│ │
│ /opt/homebrew/lib/python3.10/site-packages/modal/secret.py:102 in _load │
│ │
│ 101 │ │ │ except ImportError: │
│ ❱ 102 │ │ │ │ raise ImportError( │
│ 103 │ │ │ │ │ "Need the `dotenv` package installed. You can install it by running │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
ImportError: Need the `dotenv` package installed. You can install it by running `pip install python-dotenv`.