Can't deploy python code to heroku - python

so I just started to learn make a python bot and deploy it to heroku. I want to make a line bot.
I follow the instructions in Line and for tutorial, I download the sample-echo python file and want to try deploy it to heroku.
I follow the instructions in heroku step by step, and when i want to do
$ git push heroku master
i got error
-----> Failed to detect app matching https//codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/python.tgz
buildpack
Push failed
i already set the buildpacks to python and this is the ss of the master directory
this is the master directory
I really hope that someone could help me solve this error, and anyway, can anyone suggest a good web to learn make line chatbot using python?
Thank you so much

This issue was adressed here
Resolution
This error message means that Heroku was unable to automatically
detect the type of app you're trying to deploy: Ruby, Node, Python,
PHP, Java, etc. We look for signatures for each language we support
(like a pom.xml file or package.json file).
Most apps have at least one of these signatures present, so if you see
this error, it usually means an important file isn't checked into your
git repository:
Java: pom.xml
Ruby: Gemfile
Node.js: package.json
Python: requirements.txt / setup.py / Pipfile
PHP: composer.json / index.php
You should git add {file}, git commit -am 'added {file}' and then git
push heroku master.
Adding the file requirement.txt in the .git folder isn't enough, you have to do the command to add it then push it. It should fix the problem.

Related

Heroku cannot detect the buildpack to use for this application automatically. error when trying to deploy/push files to heroku - any fixes?

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?
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

Running move and delete commands on Heroku CLI

I've recently deployed an application to Heroku. Due to the constraints of the file system I'm looking to replace two css files within a Flask Package upon the application starting.
My main goal is to take a file from the app directory (the file is part of the git repo) and use it to replace a python package file located in the site packages directory.
I've tried to run the following from the Heroku CLI but nothing seems to happen.
heroku run mv ./bootstrap.css ./.heroku/python/lib/python3.6/site-packages/flask_bootstrap/static/css/bootstrap.css
I've also tried to remove the files from the site packages directory using RM but again nothing happens.
Could you please let me know if standard unix commands work on Heroku?
Fork and edit flask_bootstrap and add that to requirements.txt file like this.
Heroku using ephemeral filesystem. Whatever change you made to your filesystem only last until the dyno is restarted.
So my opinion is to change the file in your local repo and push to heroku again.
Source : https://help.heroku.com/K1PPS2WM/why-are-my-file-uploads-missing-deleted

How do I host my discord.py bot on heroku?

I am currently trying to get my discord bot on to Heroku and host it 24/7 but I am having problems.
I uploaded my bot to github https://github.com/zemocode/flankebot/tree/master
I have created the two main files I needed
I clicked deploy branch on Heroku and I'm getting this error.
! 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
I have followed tutorials but everyone else has node.js and I so mine doesn't work.
You're missing a couple of things to make this work, for the sake of everyone Googling how to host discord.py on Heroku and getting this as the top result here's a step-by-step
Install Git and do git init when inside your directory
(If you're using virtualenv or similar go into it and) do pip freeze then copy the contents you get to a file called requirements.txt and save it in the same repository as the bot
Make a file (a file of type file)
, open it with notepad and write worker: python name_of_bot_file.py and save within the same repository
Make a text file called runtime.txt and paste python-3.6.5 or whichever python version you were using to write the bot and save it in the same repository.
(If you're inside virtualenv get out and) open your console and write heroku login and input your heroku login details
Then do heroku apps:create name_of_app and heroku buildpacks:set heroku/python
Finally, do git push heroku main or git push heroku branch_name:main if you want to only push one branch
your procfile isn't right. a web application(web:<command>) is for websites (which your bot isn't). the right one is worker: python3 bot.py.
Also, you need a requirements.txt. inside the file, write every module you need to download. in your case, its just discord.py.

Deploying with python 3 on Heroku

I'm trying to deploy to heroku and using python 3. However the heroku build pack defaults to python 2.7.
The build pack read me mentions that a runtime.txt file can be added to change the default runtime.
I'm not clear on the instructions but I've added a runtime.txt file to the root of my project folder with
python-3.4.3
in it. After this if I do:
heroku create
then:
git push heroku master
This doesn't work and still commences the build python 2.7.
Note I do get a custom build pack detected notification.
The information you gave is vague, but if you're following the steps exactly as you say, then you're forgetting to git add and git commit before pushing to heroku.

Openshift: How to and the Drawbacks of a Hot Deployment

I work with Openshift and in specific with Python. I have done many projects in there and I think the most irretating thing is that when you deploy your application, the server is down and you cannot even show a custom message.
I was socked after months when I searched in Google that there is an option to Hot Deploy an application. To git push it without the server get down. I am not a computer scientist, so I cannot understand if this technique has any drawbacks on my application.
Also, until now, when I wanted to update my application, I was doing:
git add .
git commit -a -m 'mycommit'
git push
I read on the manual that I have to enable the Hot Deployment with creating a file on the directory:
C:\app_directory> copy NUL > .openshift\markers\hot_deploy
But after that, how will I (hot) deploy the changes in my server?
Thank you
Once you have added the hot_deploy marker to your git repository, you need to follow the same git add, git commit, git push procedure, the only difference will be that your site will not shut down while it is being deployed. The new code will be deployed and everything should work as expected.
You need to add the marker file to your Git to make the change through to the the server.
git add .openshift/markers/hot_deploy
git commit -m "Changing application to hot deploy"
After this your subsequent commits (using the git add/commit/push combination) will not restart your server.
Alternatively you can use the following rhc commands to enable and disable auto-deployment.
rhc app-configure <app> auto-deploy
rhc app-configure <app> no-auto-deploy

Categories