Skip to content

Alembic: No module named 'app' #324

@Fingel

Description

@Fingel

With a fresh clone of this project from cookiecutter, alembic does not run:

$ alembic upgrade head
Traceback (most recent call last):
  File "/Users/austin/.virtualenvs/ccfast/bin/alembic", line 8, in <module>
    sys.exit(main())
  File "/Users/austin/.virtualenvs/ccfast/lib/python3.9/site-packages/alembic/config.py", line 581, in main
    CommandLine(prog=prog).main(argv=argv)
  File "/Users/austin/.virtualenvs/ccfast/lib/python3.9/site-packages/alembic/config.py", line 575, in main
    self.run_cmd(cfg, options)
  File "/Users/austin/.virtualenvs/ccfast/lib/python3.9/site-packages/alembic/config.py", line 552, in run_cmd
    fn(
  File "/Users/austin/.virtualenvs/ccfast/lib/python3.9/site-packages/alembic/command.py", line 298, in upgrade
    script.run_env()
  File "/Users/austin/.virtualenvs/ccfast/lib/python3.9/site-packages/alembic/script/base.py", line 489, in run_env
    util.load_python_file(self.dir, "env.py")
  File "/Users/austin/.virtualenvs/ccfast/lib/python3.9/site-packages/alembic/util/pyfiles.py", line 98, in load_python_file
    module = load_module_py(module_id, path)
  File "/Users/austin/.virtualenvs/ccfast/lib/python3.9/site-packages/alembic/util/compat.py", line 184, in load_module_py
    spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 790, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "alembic/env.py", line 23, in <module>
    from app.db.base import Base  # noqa
ModuleNotFoundError: No module named 'app'

Looking at the way the source code is organized, I'm not sure it can work unless PYTHONPATH is modified or the alembic folder is moved. Can anyone shed some light on this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions