0

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?

Dharman
  • 30,962
  • 25
  • 85
  • 135
  • Presumably you have an environment that includes SQLAlchemy and related items (such as the DBAPI driver, e.g., psycopg2). Does it not also include Alembic (e.g., `pip install alembic`)? – Gord Thompson Jan 29 '22 at 14:24
  • Hi! Yes, but fastAPI not DBAPI. But yes, I have all of those packages. Also done ```pip install alembic``` if you'd like you can check my Github-rep. https://github.com/lura00/python-API-tutorial.git – Ludvig R Jan 29 '22 at 18:00
  • @GordThompson So this is the output when I do ```heroku run alembic upgrade head``` ```$ heroku run alembic upgrade head » Warning: heroku update available from 7.53.0 to 7.59.2. Running alembic upgrade head on ⬢ fastapi-lura... up, run.9441 (Free) bash: alembic: command not found``` – Ludvig R Jan 29 '22 at 18:22
  • Does the `PATH` environment variable include the directory where Alembic is installed? – Gord Thompson Jan 30 '22 at 16:13
  • Yeah, I have added it to PATH on my Windows 10. I have started to think if maybe it is bash thats is the problem? Or perhaps heroku? – Ludvig R Jan 31 '22 at 18:52
  • `bash` on Windows 10 sounds like you might be using WSL (Windows Subsystem for Linux). Are you? If so, check the PATH envar from bash to see if it is the same as the native Windows PATH. – Gord Thompson Jan 31 '22 at 21:06
  • I mean my main OS is windows 10 which I downloaded bash on. I have WSL as well but not for bash, I use that for Ubuntu and Kali. I have added alembic, heroku and bash to the system enviromental variables (path) on my windows-system. – Ludvig R Feb 01 '22 at 15:21

2 Answers2

0

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!

Aadil
  • 1
  • 1
  • Thanks, I solved the issue by doing all the changes manually. But this could possibly work. I will have a look in my requirements-file – Ludvig R May 10 '22 at 09:28
0

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

hasangzc
  • 63
  • 7