sd-dynamic-prompts: ImportError: cannot import name 'pass_environment' from 'jinja2'

Looks like after updating Web-UI Automatic 1111 to the latest new big release 1.3.0, Dynamic prompt is no longer loading/working for me. Was working perfectly prior to this.

Error loading script: dynamic_prompting.py Traceback (most recent call last): File "D:\StableDifusion\stable-diffusion-webui\modules\scripts.py", line 263, in load_scripts script_module = script_loading.load_module(scriptfile.path) File "D:\StableDifusion\stable-diffusion-webui\modules\script_loading.py", line 10, in load_module module_spec.loader.exec_module(module) File "<frozen importlib._bootstrap_external>", line 883, in exec_module File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed File "D:\StableDifusion\stable-diffusion-webui\extensions\sd-dynamic-prompts\scripts\dynamic_prompting.py", line 3, in <module> from sd_dynamic_prompts.dynamic_prompting import Script File "D:\StableDifusion\stable-diffusion-webui\extensions\sd-dynamic-prompts\sd_dynamic_prompts\dynamic_prompting.py", line 12, in <module> from dynamicprompts.generators.promptgenerator import GeneratorException File "D:\StableDifusion\stable-diffusion-webui\venv\lib\site-packages\dynamicprompts\generators\__init__.py", line 7, in <module> from dynamicprompts.generators.jinjagenerator import JinjaGenerator File "D:\StableDifusion\stable-diffusion-webui\venv\lib\site-packages\dynamicprompts\generators\jinjagenerator.py", line 14, in <module> from dynamicprompts.jinja_extensions import DYNAMICPROMPTS_FUNCTIONS, PromptExtension File "D:\StableDifusion\stable-diffusion-webui\venv\lib\site-packages\dynamicprompts\jinja_extensions.py", line 8, in <module> from jinja2 import Environment, pass_environment ImportError: cannot import name 'pass_environment' from 'jinja2' (D:\StableDifusion\stable-diffusion-webui\venv\lib\site-packages\jinja2\__init__.py)

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 4
  • Comments: 25 (3 by maintainers)

Commits related to this issue

Most upvoted comments

me too, tried uninstalling and reinstalling, and still not working, but did manage to loose all my custom made wildcards in the process

23:41:31-521470 ERROR Module load: C:\AI\Automatic\extensions-builtin\sd-dynamic-prompts\scripts\dynamic_prompting.py: ImportError ┌───────────────────────────────────────── Traceback (most recent call last) ─────────────────────────────────────────┐ │ C:\AI\Automatic\modules\script_loading.py:13 in load_module │ │ │ │ 12 │ try: │ │ > 13 │ │ module_spec.loader.exec_module(module) │ │ 14 │ except Exception as e: │ │ in exec_module:883 │ │ │ │ … 4 frames hidden … │ │ │ │ C:\AI\Automatic\venv\lib\site-packages\dynamicprompts\generators\jinjagenerator.py:14 in <module> │ │ │ │ 13 from dynamicprompts.generators.randomprompt import RandomPromptGenerator │ │ > 14 from dynamicprompts.jinja_extensions import DYNAMICPROMPTS_FUNCTIONS, PromptExtension │ │ 15 from dynamicprompts.parser.config import ParserConfig, default_parser_config │ │ │ │ C:\AI\Automatic\venv\lib\site-packages\dynamicprompts\jinja_extensions.py:8 in <module> │ │ │ │ 7 │ │ > 8 from jinja2 import Environment, pass_environment │ │ 9 from jinja2.ext import Extension │ └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ ImportError: cannot import name ‘pass_environment’ from ‘jinja2’ (C:\AI\Automatic\venv\lib\site-packages\jinja2_init_.py)

@chuckkay does the suggested command fix your issue?

Try pip install -U jinja2==3.1