No module named alembic.__main__; 'alembic' is a package and cannot be directly executed

See original GitHub issue

I am trying to run alembic inside a venv inside of WSL-2 Ubuntu. I am using using the following command:

python -m alembic revision --autogenerate -m "create foo"

resulting in

/home/ubuntu/code/my-repo/venv/bin/python: No module named alembic.__main__; 'alembic' is a package and cannot be directly executed

python version: Python 3.7.8 alembic version: 1.4.0

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
zzzeekcommented, Aug 19, 2020

usually you should invoke alembic via the entrypoint script /path/to/venv/bin/alembic. if you want to invoke from the python executable directly you would need to say “python -m alembic.config”.

0reactions
sqla-testercommented, Oct 18, 2020

CaselIT has proposed a fix for this issue in the master branch:

Add __main__.py file to alembic package to support invocation https://gerrit.sqlalchemy.org/c/sqlalchemy/alembic/+/2313

Read more comments on GitHub >

github_iconTop Results From Across the Web

I ma trying to use alembic with fastapi and postgres sql but it ...
I ma trying to use alembic with fastapi and postgres sql but it gives me error that No module named 'database but it...
Read more >
[Fixed] ModuleNotFoundError: No module named 'alembic'
Quick Fix: Python raises the ImportError: No module named 'alembic' when it cannot find the library alembic . The most frequent source of...
Read more >
Tutorial — Alembic 1.9.0 documentation
The tutorial below assumes the alembic command line utility is present in the local path and when invoked, will have access to the...
Read more >
Execute rasa x with an error - Rasa Community Forum
_revision_map File “c:\users\jean\anaconda3\envs\rasa\lib\site-packages\alembic\util\langhelpers.py”, line 230, in get obj.dict[self.name] ...
Read more >
How can I use ExecuteSQLOp? - Google Groups
to sqlalchemy-alembic. Hi,. I have a use-case where I need to execute a function called audit_table after a new table is created in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found