I'm starting with Heroku - Python. I have created an application as is described in this tutorial: tutorial on Heroku web. Everything worked fine, I typed heroku open and webapp said Hello from Python!. So I tried to find where is Hello from Python! text situated and changed it to Hello from Python! update to learn how to update the code.
I tried to type git push heroku master as is described here: StackOverflow link but get the same problem - everything up-to-date which is not true.
Have you any ideas how to update the code? What's wrong?
You must commit your changes to your local git repository before pushing them to the heroku's repository.
You can do it with the bash command:
git commit -m "comment"
After if it doesn't work check if your python module is actually under version control:
git ls-tree -r master --name-only
And eventually you can add modules to version control:
git add <filename>
Related
Been trying to deploy my python selenium code to Heroku but I keep running into this issue:
--
Terminal command:
heroku ps:scale bot=1
Output:
» Warning: heroku update available from 7.53.0 to 7.59.2.
Scaling dynos... !
! Couldn't find that process type (bot).
Procfile:
bot: python sfkafskafne.py
(Pycharm)
I'm deploying attempting to deploy to Heroku using the PyCharm terminal with the command above
I'm deploying attempting to deploy to Heroku using the PyCharm terminal with the command above
None of the commands in your post deploy your code. heroku ps:scale scales dynos for code that has already been deployed.
Before you scale your dynos, you need to get your code onto Heroku by deploying it. You can do so via git push, GitHub integration, or Docker.
The first two options require that your code be committed to a Git repository. That's a good idea anyway, even if you choose to use Docker deployment.
For the first option, something like this should get you going:
Change to the project directory with cd INSTTTAAAAA
Create a Git repository with git init
Commit your code with git add . followed by git commit -m "Initial commit"
Add a remote with heroku git:remote
Push your code with git push heroku main
Beyond this, I suggest you read the documentation I linke to above. There's lots more to learn that's beyond the scope of a SO question.
You will also want to push your code to GitHub or similar as well. Heroku is not meant to be your primary source code repository.
Side note: I'm not sure if INSTTTAAAA and sfkafskafne mean something in a language that you speak, but if these are effectively random I strongly urge you to rename them. Using good, clear names is very important.
I am deploying my project with heroku. My Django version number is 3.2.8 and python 3.9.7. It is written on heroku. Heroku supports Python 3.9.7 deployment, but there is an error in my push process. The version above does not support it. What should I do? Thank you for your reply
This is my cmd
my requirements.txt
I haven't used Heroku but I'm curious if this is a problem related to enforced nomenclature on main branch.
A while back I could not push my first commit to a new and empty Git repository if my push command was "git push origin master", it started working after I changed it to "git push origin main" so I suspect this could be the issue you're facing.
Sorry I couldn't ask you before I posted this answer if this is your first push, I do not have enough points to post a comment.
This is due to that Heroku has specific python runtimes.
Visit the link to know : Heroku Supported Runtimes Python
To solve this issue, simply create a runtime.txt file in root folder and add python-3.7.6
I'm trying to update a Docker image on my Heroku app.
I just used the following commands from this documentation article: https://devcenter.heroku.com/articles/container-registry-and-runtime
heroku login
heroku container:login
heroku container:push web
heroku container:release web
heroku open
This set of commands worked perfectly the first time, except that I got an error about not being able to map to the $PORT variable I figured out how to fix the problem (I'm using Flask), so I updated my api.py (I named it api.py instead of app.py), and now I want to push the updates to the Heroku app. But running through those commands, it seems to use the cache (I've had this problem on my local machine before; I have to use the --no-cache option when I buid). I don't really know when it's being built on Heroku.
Anyways, at the end of the release command, it says: The process type web was not updated, because it is already running the specified docker image.
How do I get it to update?
Just for the people out there looking at this, it turned out it was a simple mistake in my Dockerfile.
Basically, I was using git clone to get my app files. Because of this, I had no ADD commands anywhere, so all the results were being cached by docker.
All I had to do was run ADD instead of git clone to import my project files, and now everything runs perfectly well :)
Recently I'm learning Flask by the book "Flask Web Development". When I completed the code and deployed it to Heroku, the following error happened:
ImportError: /app/.heroku/python/lib/python3.6/
sitepackages/psycopg2/.libs/libresolv-2-c4c53def.5.so:
symbol __res_maybe_init version GLIBC_PRIVATE not defined
in file libc.so.6 with link time reference
However, this works fine locally. I have searched relevant questions about psycopg2, and I have adjusted the version of psycopg2 but the same error still happens. Please, how can I solve the problem?
I got the same problem. I solved it by forcing heroku to clean up the python virtual environment, and reinstall the requirements.txt file using psycopg2>=2.7,<2.8 --no-binary psycopg2. I must admit it felt a little like magic, but for what its worth here are the steps I took:
Using Git Bash for Windows, I logged in to heroku with heroku login.
Next, I navigated to the root folder of the git/project folder I was working on.
There I made sure that my requirements.txt was updated by running venv/Scripts/pip freeze > requirements.txt. You will probably have to find your own python/virtual environment path.
Next I changed the line/entry for psycopg2 to psycopg2>=2.7,<2.8 --no-binary psycopg2.
Then saved all the content of the requirements.txt file to my desktop, making sure the one in my project folder was empty. Not sure if this step was necessary. But that's what I did, so I'm just gonna mention it here.
Now in the Git Bash terminal I ran heroku apps:info -a blogglistene to find the version of the my heroku stack which for me was heroku-18.
Next I look online for the supported versions of python for heroku-18. It said the default was python-3.6.6 (which I then assumed is the one I was running), and some others.
I then picked python-2.7.15 arbitrarily from the list, and added that text to a runtime.txt file which I placed in the root of my project folder.
Next I committed and pushed this to my heroko git repo, and it was deployed. This will temporarily break the build. From what I understand, the magic behind this is that heroku now fully destroys the python interpreted and environment, so no lingering cached files or anything. Clean slate.
Then I reverted the content of runtime.txt to the default of python-3.6.6 and added back the content of the requirements.txt file, making sure the changes I made are there.
Finally, I committed and pushed this, and my application was back up and running.
I had the exact same problem when I was following "Flask Web Development". I spent a day plus trying to solve it and eventually succeeded. It's not as complicated as André C. Andersen's method.
Make sure you are on master branch. Not other branches.
The book is second edition of Flask Web Development by Miguel Grinberg. Chapter 17. Deployment. When you work all the way till Deploying with git push, after git push heroku master to upload the application to the heroku remote. The application is now deployed and running, but it is not going to work correctly because the deploy command that initializes the database tables has not been executed yet. You need to use
heroku run flask deploy
to create database on heroku. That's where the problem appears.
This is because at this point your git repo HEAD is at 17c. It's not the master branch yet. If you commit any change now, it won't change heroku environment. Meaning when you do
git branch
You will see:
(HEAD detached from 17c)
master
But this is not what you want. Not head attached to 17c. You want to see only master, which is achieved with
git checkout master
Then git branch will show only master branch. Therefore you can make adjustments on the project and heroku will update. Doing this because you will eventually git push to master branch. I think you can git push to other branches in order for heroku to work, but I don't know how to do that.
Change psycopg2==2.7.3 to the newest version, e.g. psycopg2==2.8.4. Another workaround is to change it to psycopg2-binary==2.8.3.
psycopg2 2.7.3 will give you GLIBC_PRIVATE error. (You can check it by running heroku run bash, then starting python and importing psycopg2. If heroku dependency is 2.7.3, then you will see the same error.) The official website notes that version 2.7.3.1 drops libresolv which causes the issue, therefore using this version or later should do the trick.
Now, change your requirements/heroku.txt (heroku environment dependency) line psycopg2==2.7.3 to psycopg2--2.8.4 or psycopg2-binary==2.8.3. (For some reason binary version of psycopg2 will work without issue. Don't know why, but I saw A LOT of discussion on stackover.) Then,
git add .
git commit -m "notes"
As usual.
git push heroku master
Push to heroku master branch. If you do not do step 1, then git will show Everything up-to-date. Therefore, it won't make changes because you are committing not to master. Now, you can see git is downloading the appropriate package.
You can double check if the packages are correct by opening heroku bash then pip list. You will see psycopg2 (and psycopg2-binary if you chose the workaround). Now, when you start Python, you can import psycopg2 with no problem.
Finally. heroku run flask deploy. Voila!
I was stuck on step 1, since whatever change I made with the project, heroku just didn't update.
I've tried other peoples solutions to getting there procfile recognised and it's just not working for me. Really confused about how I can get heroku to recognize my Procfile! I've moved it around into different folders and whatnot but it just won't recognise it.
web: waitress-serve --port=$PORT alex1.wsgi:application
This is my code. It's sitting right next to my requirements.txt file which is getting picked up by heroku fine. using echo to create the file or even echo is not working.
https://github.com/Hewlbern/Videography-Website/tree/master/Alex1 <--- the github link that I'm trying to deploy to heroku from. Can see where i've placed it and etc if anyone can help!
Such sad, many mad.
EDIT
Put them at top of directory - still not working.
Here's the error log.
-----> Python app detected
! Warning: Your application is missing a Procfile. This file tells Heroku how to run your application.
! Learn more: https://devcenter.heroku.com/articles/procfile
-----> Installing requirements with pip
-----> $ python manage.py collectstatic --noinput
63 static files copied to '/tmp/build_b9ce82b65ae441b651c56911a7474859/Hewlbern-ConsultingPage-1720e65/djreact/static/root'.
-----> Discovering process types
Procfile declares types -> (none)
-----> Compressing...
Done: 64.3M
-----> Launching...
Released v19
https://consultingpage.herokuapp.com/ deployed to Heroku
In response to Mike's point below I went through his example I reached this point.
C:\Users\Holbinator\Desktop\Software Dev\Alexandria>git push heroku master fatal: 'heroku' does not appear to be a git repository fatal: Could not read from remote repository.
I then re-did Git Init in the root directory and then tried to load the code from Github.
This led to the same issue.
I'll put this in my edit. Thanks! I'm going to try and do your method now and work out why I couldn't in this instance.
EDIT TWO
Now realised I needed to delete a extra heroku app. Now loading the files using heroku cli. Have no received an error, unsure how to access error logs but will try and solve the issue now.
First point of my recommendation will be to put .idea directory in .gitignore file.
I've uploaded your application on heroku and as result -Procfile was added successfully.
Steps:
git add . in your root directory
git commit -m "init commit"
heroku create
git push heroku master
That's mine result, but you will probably see something similar to this :
Afterwards I've launched your application via heroku open command and received the 500 error.
Screenshot of logs
I hope this answer will be useful, also read about deploy on heroku
UPD: Please check if you using git init in your root directory of project