added build pack and it's not showing up - python

I'm trying to use Heroku buildpacks to allow me to run PhantomJS from a Flask app. I've tried to follow the advice here and after I add the buildpacks and push, I still only see heroku/python when I check with heroku buidpacks at the command line.
After some research it seemed maybe multiple buildpacks is not supported and I needed to try what this site recommended. I added the
$ heroku config:
add BUILDPACK_URL=https://github.com/ddollar/heroku-buildpack-multi.git
created the .buildpacks file in the project root with the following:
https://github.com/heroku/heroku-buildpack-python
https://github.com/stomita/heroku-buildpack-phantomjs
and modified the path, as recommended:
$ heroku config:add LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:/lib:/app/vendor/phantomjs/lib
after pushing, still I see only heroku/python when i try heroku buildpacks.
Also, for what it's worth the below test doesn't work for me, because there is no vendor directory. I'm not sure where that directory even comes from, but it was never in my project, so I can only assume that the buildpacks are suppose to create it? I found countless references to this directory, and adding this directory to the Heroku path, but not a single one explained it's origin, other than to say that is where the phantomJS buidpack installs to
$ heroku run bash
$ vendor/phantomjs/bin/phantomjs

For anyone who gets stuck on this...
Rather than this:
$ heroku config:
add BUILDPACK_URL=https://github.com/ddollar/heroku-buildpack-multi.git
You actually need to do the this: (as outlined here):
$ heroku buildpacks:
set https://github.com/ddollar/heroku-buildpack-multi.git

Related

How to set Heroku profile so it accepts "yes" in any terminal question for Heroku Deployment

I am trying to run a command while deploying my Django code to Heroku. I want to accept any question it might get in terminal.
I tried to add following to the procfile, but it didn't work.
release: python manage.py collectstatic --yes
release: python manage.py collectstatic -y
What is the correct way to do this?
This is a common issue while deploying Django project on Heroku. Like it was suggested before, if you run through Git, Heroku will run the command for you. So, if you still get error on heroku and not locally that means you havent add all the files to git before pushing. Try that it should work.
If the problem still persist, try this
The correct format for this command is python manage.py collectstatic --noinput. However, if your using Git to deploy, Heroku should already run this command for you.

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

Running simple python script continuously on Heroku

I have simple python script which I would like to host on Heroku and run it every 10 minutes using Heroku scheduler. So can someone explain me what I should type on the rake command at the scheduler and how I should change the Procfile of Heroku?
Sure, you need to do a few things:
Define a requirements.txt file in the root of your project that lists your dependencies. This is what Heroku will use to 'detect' you're using a Python app.
In the Heroku scheduler addon, just define the command you need to run to launch your python script. It will likely be something like python myscript.py.
Finally, you need to have some sort of web server that will listen on the proper Heroku PORT -- otherwise, Heroku will think your app isn't working and it will be in the 'crashed' state -- which isn't what you want. To satisfy this Heroku requirement, you can run a really simple Flask web server like this...
Code (server.py):
from os import environ
from flask import Flask
app = Flask(__name__)
app.run(environ.get('PORT'))
Then, in your Procfile, just say: web: python server.py.
And that should just about do it =)
If you use free account [unverified*] on Heroku (so you cannot install addons), instead of using "Heroku scheduler", use time.sleep(n). You don't need Flask or any server in this case, just place script, say, inside folder Scripts (in default app/project by Heroku) and add to Procfile: worker: python script.py. Of course you replace script.py with Path to your script, including name, ex. worker: python Scripts/my_script.py
Note: If your script uses third-party modules, say bs4 or requests, you need to install them in pipenv install MODULE_NAME or create requirements.txt and place it where manage.py, Procfile, Pipfile, (etc) are. Next place in that requirements.txt:
requirements.txt:
MODULE_NAME==MODULE_VERSION
You can check them in pip freeze | grep MODULE_NAME
Finally deploy to Heroku server using git and run following command:
heroku ps:scale worker=1
That's it! Bot/Script is running, check it in logs:
heroku logs --tail
Source: https://github.com/michaelkrukov/heroku-python-script
unverified* - "To help with abuse prevention, provisioning an add-on requires account verification. If your account has not been verified, you will be directed to visit the verification site." It redirects to Credit Card info. However you can still have Free Acc, but you will not be able to use certain options for free users, such as installing addons:https://devcenter.heroku.com/articles/getting-started-with-python#provision-add-ons

Launching an app in heroku? What is procfile? 'web:' command?

I was referring to this site as i am learning python/flask and trying to use heroku.
http://ryaneshea.com/lightweight-python-apps-with-flask-twitter-bootstrap-and-heroku
Let me explain what all I did, so that any one who is stuck like me can get the picture.
I am using Linux Backtrack command line .
1. I started virtualenv and then installed flask
virtualenv --distribute
pip install flask
Then, connected heroku and github, created a repo also in the github.
Wrote a simple script and saved it in app.py
Then, asked to create a procfile!
web: python app.py
Questions.
1. What is procfile in layman terms?
2. When i type web: python app.py, it says 'web:: command not found'
Please elaborate how this works?
I have one more doubt, sudo is supreme user right?
We are not supposed to use it in virtualenv?
And for what exactly are we using virtualenv? A simple example.
Questions are pretty basic. DO bare.
the Procfile tells Heroku what commands should be run (https://devcenter.heroku.com/articles/procfile).
You are able to define difference process types, such as web (the only one which will autostart by default), workers, etc...
So basically a Procfile containing
web: python app.py
is telling Heroku to started a named process called web, and to run python app.py when it starts.
There is Python specific documentation for Heroku at https://devcenter.heroku.com/articles/getting-started-with-python#declare-process-types-with-procfile

Heroku Django: Reconnecting and Updating

I've finished the Heroku tutorial on how to upload and launch a basic django based web app using the following:
https://devcenter.heroku.com/articles/django#gitignore
Can anybody provide steps or a link to documentation on how to re-connect to Heroku and properly upload changes you've made to your site? Starting from a fresh terminal and cd'ing into the folder where your manage.py and procfiles live, what would the following steps be?
I then do:
$ virtualenv venv --distribute
$ source venv/bin/activate
after this i try to run $python manage.py runserver but it can't find django modules etc...
Do I need to reinstall django everytime I go to git push an update on the server?
To answer your question:
Heroku is just git, basically. At least on your computer.
So you don't need to "connect" to Heroku. You just cd to your source folder and use it as you would a normal git repository.
If you're using a virtualenv (which you should be), after you cd to your directory, you'll need to reactivate the virtualenv. If you followed heroku's Django tutorial, it'll probably be the command source venv/bin/activate
If you want to dig into some of herokus commands, download the Toolbelt.
To test whether your Procfile is working, use Honcho. It's a python version of foreman, Heroku's Ruby-based local Procfile runner.
To see which files are on your Heroku app:
Launch the bash on heroku by typing this command on your terminal:
heroku run bash --app appname
From there just ls and see your folders.

Categories