I am trying to deploy my python flask app to heroku but it keeps crashing and complaining about bash: gunicorn: command not found. I have my requirement.txt file in the root folder where my Procfile is also located. My python code is located in src/server/
Procfile contains: web: gunicorn --pythonpath src/server/ route:app --preload
I have gunicorn in my requirements file:
Is there something i'm missing?
gunicorn==19.8.1
Flask==0.12.2
Flask-Cache==0.13.1
Flask-Cors==3.0.2
Flask-MongoAlchemy==0.5.1
flask-mongoengine==0.9.5
Flask-PyMongo==0.5.2
Flask-WTF==0.14.2
gevent==1.2.1
greenlet==0.4.12
pymongo==3.6.1
folder structure;
I faced a similar problem with my app. I just reset all my requirements by sending in an empty requirements.txt file. Then built my app. Then sent the original file. I don't understand why, but it worked.
I am also having a similar problem like this on Heroku. I created an IDENTICAL new project and magically it works. Heroku has some bug related to ignoring requirements.txt
I fixed it by creating a new environment in Heroku. The previous environment seems not to be reading the requirement.txt file, I couldn't figure why.
Related
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 have a REST API exposed with Falcon and Waitress. It works fine in my local environment and want to publish it in Heroku.
To start the API, in my Procfile I have the following:
web: waitress-serve --port=$PORT app:api
And I can't see it correctly in the Free Dynos resources.
But when I deploy in Heroku, I get the following error message:
bash: waitress-serve: command not found
I'm using the following Buildpack:
https://github.com/teamupstart/conda-buildpack
In my root folder, I have conda-requirements.txt with waitress==1.3.0
Am I missing anything?
My fix for this was that I had not updated my requirements.txt file with my most recent installs. Do that, git push, and it might work.
I'll add also that my Procfile is this:
web: waitress-serve --port=$PORT --call myapp:create_app
I'm trying to build up a deep-learning-based facebook chatbot (using Python). I'm trying to deploy it on Heroku firstly, but as I'm using the command web: gunicorn echoserver:app the terminal says web: command not found. Howevere, I've installed gunicorn already.
This is because you are typing web:, which is not a command line interface (CLI) command.
If you've installed gunicorn, then the command (from the CLI) is gunicorn. Something like, for instance
gunicorn echoserver:app
I suppose it's also possible that you have a Windows machine. gunicorn does not work on Windows, so you would need to use something like waitress. With waitress, you would type web: on a Windows machine, so that it would be something like
web: waitress-serve echoserver:app
Note that the procfile is literally a file you place in your repository. The contents of the procfile should contain the command you want Heroku to run to start your server.
So in the root directory of your repo, you should have a Procfile (named exactly that with no file extension) with the following contents:
web: gunicorn echoserver:app
The first part (web:) is just used to tell Heroku which dyno to run the second part (the command) on. So Heroku will only run the command on web dynos and not on background dynos.
More info here: https://devcenter.heroku.com/articles/procfile
I'm trying to deploy a simple python bot on Heroku but I get the error
couldn't find that process type
When I try to scale the dynos. I already made a procfile and it looks like this:
web: gunicorn dep:app, where "dep" is the name of my python code
What could be the reason?
This may happen if your procfile is misspelt, such as "procfile" or "ProcFile" etc. The file name should be "Procfile" (with a capital P).
sometimes changing the file name is not anough, because git wouldn't spot the change. I had to delete the Procfile completely, then commit the change, than add it again with the right name, and then commit that again:
remove your procfile
git commit
add a new procfile with the exact name "Procfile"
commit again
git push heroku master (or main - new heroku projects now uses main)
should work!
Make Sure Procfile should not have any extension like .txt
otherwise this will be the error
remote: -----> Discovering process types
remote: Procfile declares types -> (none)
To create file without extension type following in cmd
notepad Procfile.
Now add web: gunicorn dep:app and save
Now when you will git push heroku master the above lines will be like
remote: -----> Discovering process types
remote: Procfile declares types -> web
And the error is gone when you will run
C:\Users\Super-Singh\PycharmProjects\URLShortener>heroku ps:scale web=1
Scaling dynos... done, now running web at 1:Free
Ensure that the Procfile is in the root directory of your repository.
In my case I had initially kept the Procfile in a subdirectory. Moving it to the root directory solved the problem.
For people who are trying to deploy a django web app, take note that the above step may cause another issue - of heroku unable to reach till the wsgi file residing in the subdirectory.
I solved it by referring to the below thread -
How can I modify Procfile to run Gunicorn process in a non-standard folder on Heroku?
The following worked for me.
As per this Heroku help page:
To fix:
Remove the existing buildpacks with heroku buildpacks:clear.
You will need to add an empty commit and redeploy for the changes to
take effect:
git commit --allow-empty -m "Adjust buildpacks on Heroku"
git push heroku master
You might check your python version. I tried to deploy my Django project so my procfile looks like this web: gunicorn blog.wsgi --log-file - and I also got the same error couldn't find that process type. and I found that Heroku only support python-3.6.4 and python-2.7.14 while I just had python3.5. You can type:
python -V
to see what python version you are using now. if not, you can download python 3.6. I followed this How do I install Python 3.6 using apt-get?
Ubuntu 14.04 and 16.04
If you are using Ubuntu 14.04 or 16.04, you can use Felix Krull's
deadsnakes PPA at
https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa:
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.6
Alternatively, you can use J Fernyhough's PPA at
https://launchpad.net/~jonathonf/+archive/ubuntu/python-3.6:
sudo add-apt-repository ppa:jonathonf/python-3.6
sudo apt-get update
sudo apt-get install python3.6
and remember to keep you python 3.5. Don't remove it. and specify your python version in the runtime.txt file: python-3.6.4 and run:
heroku ps:scale web=1 --app [my app's name]
and the problem solved. I hope my answer might help you.
In My case the error was solved by just creating space between web and gunicorn
Before:
web:gunicorn --pythonpath app app.wsgi
After:
web: gunicorn --pythonpath app app.wsgi
While it's not Python, in my case, I had heroku/java followed by heroku/pgbouncer. In Heroku's Settings, I switched them so heroku/pgbouncer was on top. This fixed the issue. Perhaps your buildpacks need to be ordered differently if you are using multiple.
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.