Describe the bug
In a DataLab instance installed via the MSI installer (frozen/PyInstaller build), triggering Demo mode (toolbar action or menu entry) crashes with a traceback instead of running the demo scenario:
Traceback (most recent call last):
File "guidata\qthelpers.py", line 377, in <lambda>
File "datalab\gui\main.py", line 2308, in play_demo
File "pyimod02_importers.py", line 457, in exec_module
File "datalab\tests\__init__.py", line 33, in <module>
ModuleNotFoundError: No module named 'pytest'
Root cause (identified in code)
DLMainWindow.play_demo() in datalab/gui/main.py (line 2304) calls
datalab.tests.scenarios.demo.play_demo(), which does
from datalab.tests import datalab_test_app_context (datalab/tests/scenarios/demo.py,
line 31). This triggers the import of datalab/tests/__init__.py, which has
import pytest at module level (line 33).
Since pytest is a test-only dependency, it is not bundled by PyInstaller in the
MSI/standalone build, so any code path that imports datalab.tests (even indirectly,
just to reuse the demo/test-context helper) fails at runtime in frozen installations.
To Reproduce
- Install DataLab using the official MSI installer (not from a development/pip
environment with pytest available).
- Launch DataLab.
- Trigger Demo mode (toolbar action or menu entry calling
play_demo).
- Observe the
ModuleNotFoundError: No module named 'pytest' traceback (visible in
the console, or via the error dialog/log).
Expected behavior
The Demo mode should run correctly in installed/frozen builds, without requiring
pytest (a development/test dependency) to be present.
Environment
- Installation type: MSI installer (frozen/PyInstaller build)
- Affected versions: 1.1.0, 1.2.2, 1.3.0 (confirmed on multiple releases — long-standing
regression)
- OS: Windows
Possible fix directions
- Decouple
datalab.tests.scenarios.demo from datalab.tests.__init__ (e.g., move
datalab_test_app_context to a module that doesn't import pytest), or
- Make the
pytest import in datalab/tests/__init__.py lazy/optional, or
- Bundle
pytest as a hidden import in the PyInstaller spec (less desirable, increases
installer size for a test-only dependency).
Describe the bug
In a DataLab instance installed via the MSI installer (frozen/PyInstaller build), triggering Demo mode (toolbar action or menu entry) crashes with a traceback instead of running the demo scenario:
Root cause (identified in code)
DLMainWindow.play_demo()indatalab/gui/main.py(line 2304) callsdatalab.tests.scenarios.demo.play_demo(), which doesfrom datalab.tests import datalab_test_app_context(datalab/tests/scenarios/demo.py,line 31). This triggers the import of
datalab/tests/__init__.py, which hasimport pytestat module level (line 33).Since
pytestis a test-only dependency, it is not bundled by PyInstaller in theMSI/standalone build, so any code path that imports
datalab.tests(even indirectly,just to reuse the demo/test-context helper) fails at runtime in frozen installations.
To Reproduce
environment with
pytestavailable).play_demo).ModuleNotFoundError: No module named 'pytest'traceback (visible inthe console, or via the error dialog/log).
Expected behavior
The Demo mode should run correctly in installed/frozen builds, without requiring
pytest(a development/test dependency) to be present.Environment
regression)
Possible fix directions
datalab.tests.scenarios.demofromdatalab.tests.__init__(e.g., movedatalab_test_app_contextto a module that doesn't importpytest), orpytestimport indatalab/tests/__init__.pylazy/optional, orpytestas a hidden import in the PyInstaller spec (less desirable, increasesinstaller size for a test-only dependency).