'Error: trying to push Table SQLAlchemy models to my production heroku-server using Alembic

I am trying to push my SQLAlchemy-models to create Tables in my heroku-postgres-database. I use this command:

heroku run alembic upgrade head

It starts to Run as expected. But after a while I just get error,

Bash: alembic: command not found.

How to resolve it?



Solution 1:[1]

I had the same problem and solved it, not sure it will work for everyone. I noticed that in my requirements.txt file, I did not have the alembic package listed. So alembic was not installed loading the files on Heroku! I tried using heroku run pip install alembic, which installed the package successfully but still didn't solve the problem! I tried heroku run alembic --version, still the same.

The way I solved it is by deleting the local requirments.txt folder and generated it again using pip freeze > requirements.txt, this time alembic was there of course! After pushing my changes to heroku everything worked fine!

Solution 2:[2]

I think you are using quotes in the command. If so, remove the quotation marks

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Aadil
Solution 2 hasangzc