How to deploy pytesseract to Heroku - python-3.x

I have a Python app which words great via Localhost on my machine.
I am trying to deploy it to Heroku. However it does not seem possible to accomplish this (I have spent approx 30 hours trying now).
The problem is Tesseract OCR. I am using the pytesseract wrapper, and my code utilises this. However, no matter what I try, it does not seem to be possible to use pytesseract when it is uploaded to Heroku.
Could anyone either suggest how to go about deploying a Hello World Tesseract OCR Python app via pytesseract to Heroku, or if Heroku is not capable of this, suggest an alternative to Heroku?

For anyone else looking to deploy pytesseract on heroku, here are the steps:
Add apt buildpack to heroku
heroku buildpacks:add --index 1 https://github.com/heroku/heroku-buildpack-apt
Create a file named Aptfile in the same directory as your app and these lines to it (for english)
tesseract-ocr
tesseract-ocr-eng
Set heroku config variable TESSDATA_PREFIX to the path of tessdata folder (it was /app/.apt/usr/share/tesseract-ocr/4.00/tessdata for me) which can be found out by running heroku shell using heroku run bash and run this command in the shell
find -iname tessdata
Set the config variable using
heroku config:set TESSDATA_PREFIX=/app/.apt/usr/share/tesseract-ocr/4.00/tessdata
replace the path with the path you got from the previous command
Tesseract should be installed in the heroku app when you build it. Make sure you have pytesseract in your requirements.txt file. Now you should be able import and use pytesseract on heroku

The Python buildpack likely doesn't have the tesseract binaries installed by default. Here’s a third-party buildpack that creates the appropriate environment. Follow the instructions there to make the binary available to your application.

Related

How to obfuscate Python code with buildpacks?

I am using pack cli to build docker image for my python flask app running with gunicorn.
Inside docker image, my whole code is exposed in workspace folder.
What shall i do to restrict user to access folder or obfuscate my code?
I am using Google Buildpack
pack set-default-builder gcr.io/buildpacks/builder:v1
I'm assuming you're using the Heroku Python Buildpack (and the heroku/buildpacks:18 builder).
You can create a bin/post_compile and use it to run compileall, and then run rm **/*.py

Is there a way to install GraphicsMagick on Heroku?

I want to use gm package to generate thumbnail image (50x50) but I must install graphicsmagick in my Heroku server. So I googled it ,but haven't got a solution.
2021 Update:
I managed to install GraphicsMagick on my NodeJS Heroku project.
You just have to add heroku-buildpack-graphicsmagick
into your project.
Right now there are a lot of methods, but the fastest one is:
Go to your Heroku Dashboard > Your Project > Settings tab
Scroll down to your Buildpacks section.
Add the buildpack .git link:
https://github.com/xerpa/heroku-buildpack-graphicsmagick.git
Save and deploy your app again. Then it will be instaled.
Here's how it should look:
Now it should work.
If you're interested in my case:
I was trying to add a library to create barcodes into a pdf. For that I used a library called barcode and pdfkit. Then in order for the barcode library to work, I had to have a working installation of GraphicsMagick. Then I discovered that I had to install this 'gm' dependency into my Heroku project.
Also, this is how it looks when deploying your project:
GraphicsMagick app detected
+ install GraphicsMagick-1.3.19
I din't install anything on Heroku but It works I think GraphicsMagic is default

Vue.js Heroku deploy not working

I'm trying to deploy a Vue.js application I made to Heroku, but I keep getting Cannot find module '/app/index.js'.
I feel like I'm just missing something small. Here is the git repo if you are wanting to look through the code. https://github.com/Relofr/calculator
You need app.js (as an example) file in your main directory with basic server configuration. You also have to run npm run build before deploying your app.
Follow this tutorial:
https://medium.com/netscape/deploying-a-vue-js-2-x-app-to-heroku-in-5-steps-tutorial-a69845ace489
You don´t have any file with the name index.js try to rename ./src/main.js to ./src/index.js

How to download Node.js project deployed on Google Cloud

I have deployed the Node.js code on Google Cloud using following command:-
gcloud app deploy
So, How to download Node.js project deployed on Google Cloud.
I'm not sure but if you need Tomcat server then set and deploy node.js application inside by creating a folder and add the dist folder files in it.
npm install --save #google-cloud/storage
At this point in time it is only possible to download your app's source code for Java, Python, PHP and Golang. The instructions are similar for Python, Golang and PHP:
appcfg.py -A [YOUR_PROJECT_ID] -V [YOUR_VERSION_ID] download_app [OUTPUT_DIR]
where:
[YOUR_PROJECT_ID] is your GCP project ID.
[YOUR_VERSION_ID] is the version ID of your application that you want to download.
[OUTPUT_DIR] is the full directory path to where you want your files downloaded.
In Java you use appcfg.sh:
appcfg.sh -A [YOUR_PROJECT_ID] -V [YOUR_VERSION_ID] download_app [OUTPUT_DIR]
See the link above and also the reference for Java and Python, PHP, Golang

Can I directly use imagemagick in Heroku on node.js

I'm going to deploy my web app soon on Heroku (standard). So can I simply start using Imagemagick right off the bat or not? I already have it installed locally on my computer and obviously have the module required as well in my app.
So will it work exactly as it's working on my machine? like resizing images and getting the src path of images from specific folders like I have on my computer (I'm a newbie at deployment sorry).
You have to add the imagemagick buildpack on heroku:
heroku buildpacks:add --index 1 https://github.com/ello/heroku-buildpack-imagemagick.git
And then you can use a library to call imagemagick

Resources