카테고리 없음

Download Heroku Cli For Mac

diaconvocie1971 2021. 2. 15. 10:54


Since heroku CLI is a ruby gem, in order to install it, you will need to install ruby locally on your machine.Installing the latest Ruby version with RVM is simply done by typing: rvm install 1.9.3. Note that if you do not have rvm installed, you can install it on mac/linux. Heroku CLI has been successfully installed on your system. To verify,Run the following command in the Command Prompt or Terminal. For checking the version of Heroku, Run the following command in the terminal: heroku -v. So, the Heroku CLI has been installed properly of your system. Step 5: Signing up for the Heroku services.

In my previous post, I created a Twitter Sentiment Analysis Application and worked on deploying the app. Honestly, it was my first machine learning model deployment and it was a good start.

But, something was missing!

It lacked accessibility to people. Do you know what I mean? Everyone doesn’t need to know about Machine Learning Models and Flask and HTML. An application/app should be something that people can open and use and not worry about its complexity. Right?

So, I was basically looking for a platform and today I am going to try Heroku.

Well, what I found out is that before deploying on Heroku, we need to spend some time on the setup part. Oh well, I did! Even if I deployed the code, there was an “Application Error” and the app was not running.

So, this post is all about setting up and starting Heroku app.

Let the fun begin […drumroll…]

What is Heroku?

Heroku is a platform to deploy a web application. Let’s start right here.

Signup

To use Heroku, we need to signup first. Here is the link. Please fill in the required fields and create a free account.

Then click on “Create New App” which leads to the below page.

We will enter an APP name that is available and hence accepted and then just click on “Create App“.

Once the App is created, you will be at the “Deploy” section of the app.

If you go back later for the next steps, check your dashboard, you can see the app just created above. Click on the name to follow the next set of instructions.

Installation

We need to go to the deploy tab for the next steps of installation and follow the steps inthe“Deployment method” Section. For this post, we will use the “Heroku Git” Deployment method.

Download and install the Heroku CLI.

Here is the link for the same.

Since I work on my MacOS, I have installed heroku using the below command.

Check the version of your heroku installed with the below command.

I have installed version 7.47.3.

Deploy using Heroku Git

Let’s follow the steps exactly as mentioned in the deployment section:

It will ask to hit any key to open Heroku in a Browser. Just hit a key and enter your login information in the page opened in the browser and come back to Terminal.

Create SSH keys

Now, it is supposed to offer to create an SSH key and also upload the key to your Heroku account. But somehow it did not happen for me. So, I checked my account and the SSH keys were not generated.

If the keys are not generated, you will have to create it manually as I did and then add it to your account.

Just press enter and do not change any information and you will see you keys are generated.

Add in the keys using the below command:

Check your account on Heroku and see if you can see your registered SSH keys. Apparently, once your keys are in place, you are all set to deploy any app you want.

Create a new Git Repository

I have created a folder and have put all my files, related to that app in that folder. Go to the directory and initialize it.

Download Heroku Cli For Windows

Create Virtual Environment

In our project directory, we will create a virtual environment with the below command.

How To Update Heroku Cli

The above command will create the following directory structure:

Activale the virtual environment with below command:

Install flask and gunicorn

Then, let’s install the libraries we’re going to use

  • flask to build the app and
  • gunicorn as our server:
Create requirements.txt

We need to create a file with the libraries and the version that the application is using. To create the file, we will use the below command:

A requirements.txt file is created with the below libraries:

click7.1.2
Flask1.1.2
gunicorn20.0.4
itsdangerous1.1.0
Jinja22.11.2
MarkupSafe1.1.1
Werkzeug1.0.1

Create runtime.txt
Heroku cli download

Create another file with the python version you are using. So I created with and just added the version “python-3.7.1“.

Download Heroku Cli For Mac

Create Procfile

To successfully deploy an application on Heroku, we must create a procfile and add the below text.

web: gunicorn app:app –log-file=-

Heroku Cli Tutorial

Now, we are all set to deploy our Python application on heroku. Here goes the final step:

Download Heroku Cli For Mac Os

Commit your code to the repository and deploy it to Heroku using Git

I followed the instructions in the deploy section and ran the below code.

Heroku Cli Ubuntu

But I got an error. My code was not uploaded.

Download Heroku Cli For Mac Download

error: src refspec master does not match any.

So, after a few googling, I tried the below code and it started writing the objects on Heroku.

Once, it is done writing all the objects, it will be shown that the app has been Deployed.

Now, you must be excited to run your app on Heroku? Well, I was! But Nope, I got another error.

After banging my head for some time and reading numerous blogs, I can share what worked for my scenario. We need to add all the libraries used for the application and the corresponding versions on the Requirements.txt file. Modify the requirements.txt and run the below commands again.

Well finally, my heroku app worked! I hope it work out for you too!

Thank You!

0