I have a Python trading bot which I want to run in cloud with the help of Heroku. The Python code works just fine, but when I try to push the files after add and commit, I am getting error which says heroku cannot detect the buildpack
and heroku pre-receive hook declined
I tried to fix it, but nothing seems to work. But then I tried to deploy not by pushing it from my computer, but by uploading it to GitHub and connecting my GitHub account to Heroku account.
Connecting both accounts went well, but I get this error when I tried to deploy the files:
-----> Building on the Heroku-20 stack -----> Determining which buildpack to use for this app ! No default language could be detected for this app. HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically. See https://devcenter.heroku.com/articles/buildpacks ! Push failed
The error seems pretty straight forward and directs us to visit a website. I did try some of the stuff mentioned in the website, but maybe I am doing it wrong.
Till now what I understand is Heroku is not able to detect the language I am using which is Python. How can I fix this?
Advertisement
Answer
I think there is a pretty simple solution if you have the access to the Heroku account used to deploy this app.
Direct to the app page and go under the Settings tab, you should be able to find a Buildpacks section where you can add your buildpack if not detected automatically during deployment.
Click Add Buildpack and choose Python as your custom buildpack. Problem should be solved.
P.S. If you don’t have requirements.txt in your folder, consider adding all the packages along with their versions used for your Python Flask app to this file. For example:
Flask==2.0.2 Flask-Admin==1.5.8 Flask-Bcrypt==0.7.1 Flask-DebugToolbar==0.11.0 Flask-SQLAlchemy==2.5.1 Flask-WTF==1.0.0