Deploy python on heroku without github - python

I want to deploy my project to Heroku without placing my project to github? is this possible because I have to perform these steps and getting error. Here are the step i have performed
In my project i run this command git init
then i added some files git add myProjectFiles
I create a project on Heroku through heroku create myprojectname
Then i write this command to push my project on git push heroku master and i got this error:
error: src refspec master does not match any.
some refs to 'https:///git.heroku.com/tllwebsocekt.git'error: failed to push
Then i tried this git push heroku
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream heroku master
on this error i tried this git push --set-upstream heroku master
but it also throw an error
error: src refspec master does not match any.
some refs to 'https:///git.heroku.com/tllwebsocekt.git'error: failed to push

Heroku will try build your app when you git push heroku master
In order for the app to be pushed successfully you'll need to git commit after git add myProjectFiles then specify the buildpack for you app:
heroku buildpacks:set heroku/python
After specifying the buildpack add a requirements.txt either blank or:
pip freeze > requirements.txt
git add requirements.txt
git commit
Next you'll need to specify what command heroku should run when you've pushed the app with a Procfile:
example Procfile:
worker: python main.py
Then:
git add Procfile
git commit
Finally heroku will be able to build your app and it won't reject the push:
git push heroku master
Alternatively if you have all the above in the myProjectFiles directory
Initialise git from inside your app directory:
cd myProjectFiles
git init
git add *
git commit
heroku create myprojectname
heroku buildpacks:set heroku/python
git push heroku master

Related

Why is 'git push heroku main' failing? It says "failed to push some refs to 'https://git.heroku.com/boxer55.git'" [duplicate]

When I run git push heroku master this is what I get:
C:\Users\Emanuele-PC\Desktop\project-mm-beta>git push heroku master
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 505 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> App not compatible with buildpack: https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/python.tgz
remote: More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to project-mm-beta.
remote:
To https://git.heroku.com/project-mm-beta.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/project-mm-beta.git'
The code I am trying to deploy is just one file (it's a test because it's my first time using Heroku) and it's written in Python. I have already set the buildpack (python) but it still doesn't work. How can I solve?
The Heroku Python Support will be applied to applications only when the application has a Pipfile, setup.py, or requirements.txt in the root directory.
Visit the documentation to get detailed instructions.
I just found out... It's quite a silly issue. Make sure the git repo is initialized within the project root folder. Suppose the project is a Django app and the project folder created by Django is my-project, the git repo needs to be initialized right within my-project for Heroku to work...
Add Pipfile and Procfile, and commit them. This solved it for me.
You can see the files I am speaking of on this Heroku documentation.
And here is a link to Heroku's Python buildpack on GitHub.
You can try doing:
pip3 freeze > requirements.txt
heroku buildpacks:set heroku/python
git add .; git commit -m "add requirements.txt"; git push heroku master
Note: Make sure you're in your root directory of your Python project :)
try add a file named requirement.txt
and enter anything you need like django
Step 1) First setup the buildpack (programming-language )
For example : heroku buildpacks:set heroku/nodejs
Check for more info here : https://devcenter.heroku.com/articles/buildpacks
If the issue still exists, then follow next step
Step 2) git init and currently used directory is
different, so this error is still thrown "App not compatible with buildpack:"
For example : git init command was used executed at :- C:/sample_folder/
But modules and package.json is under nested sub-folder :-
C:/sample_folder/nodejs_app/package.json
So move the files accordingly such that all the file are present under the same folder
and then run
git push heroku master
--happy coding!
I was getting this error because I was making changes to a different branch. So I was working of a feature branch, then running git push heroku master. My changes had not been merged into my master branch, so thus the error. Once I merged in the Procfile to master I was able to push the changes up to heroku.
I was having the same error because I was not committing the files, make sure you run the command git add . then git commit -m'message' after changing any file, and then you can run git push heroku master and also add the requirements.txt and Procfile correctly.
First file: requirements.txt
containing something like: gunicorn==19.7.1 or whatever the results of pip freeze > requirements.txt are.
Second file: Procfile
containing something like: web: gunicorn app:app or potentially blank. Note that app:app in this example is a reference to your python filename. It means that every time a web process is declared, and a dyno of this type is started, also run the command gunicorn app:app to start your web server.
Then git add . and git commit -m "added Procfile and requirements.txt".
Then run git push heroku master to push from your local master branch to the heroku remote.
I had the same issue. Just make sure that you initialized the git repo inside the django project root. That way, your .git folder, .gitignore file, manage.py, requirements.txt, etc.. are on the same hierarchical level.
You can specify the buildpack for python by this method
CLI Installation
heroku buildpacks:set https://github.com/heroku/heroku-buildpack-python.git
Finally make sure you're not ignoring requirements.txt from your .gitignore, That was my problem.
-> Make sure your requirements.txt & Procfile are in the root folder.
-> run following commands if you are not in the master branch already.
git checkout -b master
git add .
git commit -m "your commit message"
git push -u origin master
git push heroku master
Check if you did the following steps:
Activate your virtual environment.
Run on your command prompt:
pip freeze>requirements.txt
Add Procfile in your main app directory (the same where manage.py is); inside Procfile you should insert:
web: gunicorn your_app_name.wsgi
Well, same happened to me while I was creating a first-time Heroku app.
Just add requirements.txt. It will work fine.
I just removed README.md from my GitHub repository which was connected to my Heroku app, and that worked for me!
Check whether you have written correct spelling of Procfile and requirements.txt, because they are case sensitive and In my case after changing the procfile to Procfile it started working properly.
Run this command:
heroku buildpacks:set heroku/python
Also you can refer this document.

Why do I keep getting an 'App not compatible with buildpack:' error when trying to deploy my django site to Heroku? [duplicate]

When I run git push heroku master this is what I get:
C:\Users\Emanuele-PC\Desktop\project-mm-beta>git push heroku master
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 505 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> App not compatible with buildpack: https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/python.tgz
remote: More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to project-mm-beta.
remote:
To https://git.heroku.com/project-mm-beta.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/project-mm-beta.git'
The code I am trying to deploy is just one file (it's a test because it's my first time using Heroku) and it's written in Python. I have already set the buildpack (python) but it still doesn't work. How can I solve?
The Heroku Python Support will be applied to applications only when the application has a Pipfile, setup.py, or requirements.txt in the root directory.
Visit the documentation to get detailed instructions.
I just found out... It's quite a silly issue. Make sure the git repo is initialized within the project root folder. Suppose the project is a Django app and the project folder created by Django is my-project, the git repo needs to be initialized right within my-project for Heroku to work...
Add Pipfile and Procfile, and commit them. This solved it for me.
You can see the files I am speaking of on this Heroku documentation.
And here is a link to Heroku's Python buildpack on GitHub.
You can try doing:
pip3 freeze > requirements.txt
heroku buildpacks:set heroku/python
git add .; git commit -m "add requirements.txt"; git push heroku master
Note: Make sure you're in your root directory of your Python project :)
try add a file named requirement.txt
and enter anything you need like django
Step 1) First setup the buildpack (programming-language )
For example : heroku buildpacks:set heroku/nodejs
Check for more info here : https://devcenter.heroku.com/articles/buildpacks
If the issue still exists, then follow next step
Step 2) git init and currently used directory is
different, so this error is still thrown "App not compatible with buildpack:"
For example : git init command was used executed at :- C:/sample_folder/
But modules and package.json is under nested sub-folder :-
C:/sample_folder/nodejs_app/package.json
So move the files accordingly such that all the file are present under the same folder
and then run
git push heroku master
--happy coding!
I was getting this error because I was making changes to a different branch. So I was working of a feature branch, then running git push heroku master. My changes had not been merged into my master branch, so thus the error. Once I merged in the Procfile to master I was able to push the changes up to heroku.
I was having the same error because I was not committing the files, make sure you run the command git add . then git commit -m'message' after changing any file, and then you can run git push heroku master and also add the requirements.txt and Procfile correctly.
First file: requirements.txt
containing something like: gunicorn==19.7.1 or whatever the results of pip freeze > requirements.txt are.
Second file: Procfile
containing something like: web: gunicorn app:app or potentially blank. Note that app:app in this example is a reference to your python filename. It means that every time a web process is declared, and a dyno of this type is started, also run the command gunicorn app:app to start your web server.
Then git add . and git commit -m "added Procfile and requirements.txt".
Then run git push heroku master to push from your local master branch to the heroku remote.
I had the same issue. Just make sure that you initialized the git repo inside the django project root. That way, your .git folder, .gitignore file, manage.py, requirements.txt, etc.. are on the same hierarchical level.
You can specify the buildpack for python by this method
CLI Installation
heroku buildpacks:set https://github.com/heroku/heroku-buildpack-python.git
Finally make sure you're not ignoring requirements.txt from your .gitignore, That was my problem.
-> Make sure your requirements.txt & Procfile are in the root folder.
-> run following commands if you are not in the master branch already.
git checkout -b master
git add .
git commit -m "your commit message"
git push -u origin master
git push heroku master
Check if you did the following steps:
Activate your virtual environment.
Run on your command prompt:
pip freeze>requirements.txt
Add Procfile in your main app directory (the same where manage.py is); inside Procfile you should insert:
web: gunicorn your_app_name.wsgi
Well, same happened to me while I was creating a first-time Heroku app.
Just add requirements.txt. It will work fine.
I just removed README.md from my GitHub repository which was connected to my Heroku app, and that worked for me!
Check whether you have written correct spelling of Procfile and requirements.txt, because they are case sensitive and In my case after changing the procfile to Procfile it started working properly.
Run this command:
heroku buildpacks:set heroku/python
Also you can refer this document.

Heroku: python app works locally but does't on remote after git push

I'm trying to deploy a python app that supports redis and I'm currently facing a problem.
I have two git branches, one for production and one for dev and two different heroku apps (python-app, dev-python-app). My git repos are:
git remote
heroku
heroku-test
I use the fallowing commands to deploy the heroku-test to check if the app works correctly before passing to prod:
git branch dev-python-app
git add .
git commit -m "commit msg"
git push heroku-test dev-python-app:master
It says that everything's ok: "remote: Verifying deploy... done." but the app won't start.
If I check logs with: heroku logs --tail -a dev-python-app:
2022-02-09T10:36:29.000000+00:00 app[api]: Build started by user *****
2022-02-09T10:36:53.638128+00:00 app[api]: Deploy 267f3889 by user ****
2022-02-09T10:36:53.638128+00:00 app[api]: Release v21 created by user ****
2022-02-09T10:37:02.000000+00:00 app[api]: Build succeeded
The stange thing is that if I run a one-off dyno using heroku run bash -a dev-python-app and than start the python app as: python3 main.py it works perfectly.
Moreover, It'd be useful to know that I tried this mentioned steps before introducing redis support to the app and It worked perfectly so could be redis the problem?
What do you think? Thank you
I fixed that.
The problem was to scale the working process:
heroku ps:scale worker=1 -a dev-python-app

App not compatible with buildpack - Heroku

When I run git push heroku master this is what I get:
C:\Users\Emanuele-PC\Desktop\project-mm-beta>git push heroku master
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 505 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> App not compatible with buildpack: https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/python.tgz
remote: More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to project-mm-beta.
remote:
To https://git.heroku.com/project-mm-beta.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/project-mm-beta.git'
The code I am trying to deploy is just one file (it's a test because it's my first time using Heroku) and it's written in Python. I have already set the buildpack (python) but it still doesn't work. How can I solve?
The Heroku Python Support will be applied to applications only when the application has a Pipfile, setup.py, or requirements.txt in the root directory.
Visit the documentation to get detailed instructions.
I just found out... It's quite a silly issue. Make sure the git repo is initialized within the project root folder. Suppose the project is a Django app and the project folder created by Django is my-project, the git repo needs to be initialized right within my-project for Heroku to work...
Add Pipfile and Procfile, and commit them. This solved it for me.
You can see the files I am speaking of on this Heroku documentation.
And here is a link to Heroku's Python buildpack on GitHub.
You can try doing:
pip3 freeze > requirements.txt
heroku buildpacks:set heroku/python
git add .; git commit -m "add requirements.txt"; git push heroku master
Note: Make sure you're in your root directory of your Python project :)
try add a file named requirement.txt
and enter anything you need like django
Step 1) First setup the buildpack (programming-language )
For example : heroku buildpacks:set heroku/nodejs
Check for more info here : https://devcenter.heroku.com/articles/buildpacks
If the issue still exists, then follow next step
Step 2) git init and currently used directory is
different, so this error is still thrown "App not compatible with buildpack:"
For example : git init command was used executed at :- C:/sample_folder/
But modules and package.json is under nested sub-folder :-
C:/sample_folder/nodejs_app/package.json
So move the files accordingly such that all the file are present under the same folder
and then run
git push heroku master
--happy coding!
I was getting this error because I was making changes to a different branch. So I was working of a feature branch, then running git push heroku master. My changes had not been merged into my master branch, so thus the error. Once I merged in the Procfile to master I was able to push the changes up to heroku.
I was having the same error because I was not committing the files, make sure you run the command git add . then git commit -m'message' after changing any file, and then you can run git push heroku master and also add the requirements.txt and Procfile correctly.
First file: requirements.txt
containing something like: gunicorn==19.7.1 or whatever the results of pip freeze > requirements.txt are.
Second file: Procfile
containing something like: web: gunicorn app:app or potentially blank. Note that app:app in this example is a reference to your python filename. It means that every time a web process is declared, and a dyno of this type is started, also run the command gunicorn app:app to start your web server.
Then git add . and git commit -m "added Procfile and requirements.txt".
Then run git push heroku master to push from your local master branch to the heroku remote.
I had the same issue. Just make sure that you initialized the git repo inside the django project root. That way, your .git folder, .gitignore file, manage.py, requirements.txt, etc.. are on the same hierarchical level.
You can specify the buildpack for python by this method
CLI Installation
heroku buildpacks:set https://github.com/heroku/heroku-buildpack-python.git
Finally make sure you're not ignoring requirements.txt from your .gitignore, That was my problem.
-> Make sure your requirements.txt & Procfile are in the root folder.
-> run following commands if you are not in the master branch already.
git checkout -b master
git add .
git commit -m "your commit message"
git push -u origin master
git push heroku master
Check if you did the following steps:
Activate your virtual environment.
Run on your command prompt:
pip freeze>requirements.txt
Add Procfile in your main app directory (the same where manage.py is); inside Procfile you should insert:
web: gunicorn your_app_name.wsgi
Well, same happened to me while I was creating a first-time Heroku app.
Just add requirements.txt. It will work fine.
I just removed README.md from my GitHub repository which was connected to my Heroku app, and that worked for me!
Check whether you have written correct spelling of Procfile and requirements.txt, because they are case sensitive and In my case after changing the procfile to Procfile it started working properly.
Run this command:
heroku buildpacks:set heroku/python
Also you can refer this document.

I got error while using "git push heroku master"

I'm using the below given commands for push data to heroku app.
git clone https://git.heroku.com/bigpro.git
cd bigpro
git add .
git commit . -m "my test on commit"
git push heroku master
When I used git push heroku master I got something like this..
fatal: 'heroku' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Then I gave heroku open command, I got an error which is
▸ ENOTFOUND: getaddrinfo ENOTFOUND api.heroku.com api.heroku.com:443
When I got the above error I tried to change commands on terminal by using heroku git:clone -a bigpro and after made my changes, I gave git push heroku master ,I got an error
remote: ! Push rejected to bigpro. remote: To git.heroku.com/bigpro.git !
[remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'git.heroku.com/bigpro.git';
First, install the heroku toolbelt, and then type heroku login to setup your account properly.
Next, type heroku git:clone -a myapp where myapp is the name of your application in Heroku. This will pull the repository and setup the remotes correctly for you.
Next, make your changes as usual.
Then you can do git push heroku master
This happened to me after I cloned from heroku a second copy of my files. Suddenly git push heroku master wouldn't work and I'd get the same error as you. But when I tried git push origin master, it worked fine.

Categories

Resources