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.
Related
I'm trying to deploy a Node.js application with a child process that runs a machine learning algorithm. I can use this locally, but when I try to run at the Heroku server I recive some messages calling that are some libraries missing, like bellow:
ModuleNotFoundError: No module named 'pandas'
I tried to create manually the requirements.txt and put the necessary libraries there:
pandas
pymongo
dnspython
scikit-learn
scipy
selenium
webdriver-manager
textblob
But it doesn't work. Do I need to do some extra configuration?
Thank you so much for your help!
The way your Heroku dynos run your software is through something called a buildpack.
When you deploy an application to Heroku, it looks at your code and tries to figure out which programming language you are using, then based on that, will run your app using the corresponding buildpack.
For example, if you deploy an app to Heroku and the app has a package.json file in the root of your project directory, Heroku will assume your app is a JavaScript app and use the Node.js buildpack.
Buildpacks contain a number of pre-installed dependencies. For example, the Node.js buildpack contains node (so you can run your JavaScript code) as well as a number of Linux dependencies so that your app will be able to install common libraries/tools that might rely on them.
But... One downside of this buildpack strategy is that if you're deploying a Node.js app, for example, the default Node.js building will NOT come with Python and the various Python library dependencies installed. This is because Heroku supports a lot of different programming environments, and it would be slow/complex if there was just a single buildpack that had EVERYTHING installed. It'd be crazy!
So what you need to do, in your case, is use multiple buildpacks! Heroku has a way for you to enable multiple buildpacks for your app so that your app can have the Node.js dependencies as well as the Python dependencies, for example!
This article on Heroku's documentation site explains how to use multiple buildpacks for a given app.
Here are the specific instructions for simplicity's sake:
# This command will set your default buildpack to Node.js
$ heroku buildpacks:set heroku/nodejs
# This command will set it up so that the Heroku Python buildpack will run first
$ heroku buildpacks:add --index 1 heroku/python
By doing the above, you'll be able to have Heroku install your Python dependencies via a traditional requirements.txt file like you would with any normal Python application.
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.
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.
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
I'm deploying a Python application to Heroku.
I have a requirements.txt file in which I install a dependency from a git repo, pinned to a certain tag, let's say:
git+git://github.com/django/django.git#1.7c2#egg=django
When I redeploy this, e.g. after changing the tag reference to 1.7c3, Heroku does not update this dependency. (As can be seen with heroku run pip list.)
As a workaround, I have found that you can modify your runtime.txt (make it reference an older Python version), commit, push to Heroku (which rebuilds the entire environment), then undo the commit and force push to Heroku again (which rebuilds the entire environment again). This is of course not a very satisfying solution in the long-term (and I don't like the idea of having to deploy my production app twice).
Is there a better solution? Any improvements on the horizon?
This will work as expected if you use the following line in requirements.txt:
-e git+git://github.com/django/django.git#1.7c2#egg=django