python + django + scikit-learn + mecab (2) on heroku

Continuing from the last time, a memo for making a python application on heroku This time, I will focus on the errors that were caught in the development.

Reference source: https://gist.github.com/konitter/5370904 http://voluntas.hatenablog.com/entry/20110919/1316426034 http://qiita.com/nakazye/items/48651e39f07da82fe79e

install heroku

The main body of heroku is

$ sudo gem install heroku

You can install it with, but an error occurs immediately ...

Operation not permitted - /usr/bin/…/

It seems that the installation folder does not have permission, it is solved by changing the installation folder

$ sudo gem install -n /usr/local/bin heroku

(Reference source: http://qiita.com/AcaiBowl/items/4bb4708de03e6ee14a4a)

virtualenv

Create a folder for development

$ mkdir heroku-django
$ cd heroku-django

In the created folder, expand virtualenv. It is recommended to develop with virtualenv on heroku! !! (To minimize the required libraries)

$ virtualenv --no-site-packages .
$ source bin/activate

Installation of required packages

$ pip install django
$ env ARCHFLAGS="-arch i386 -arch x86_64" bin/pip install psycopg2
$ pip install gunicorn

Record the installed libraries in requirements.txt in the heroku_django directory

$ pip freeze > requirements.txt

Creating a Procfile

Create a Procfile on heroku_django directory (required to use gunicorn on heroku) I stumbled because it didn't move easily

Procfile


web: gunicorn --pythonpath './mysite' mysite.wsgi --log-file -

It's okay with one line. The point is to specify the python path

From here, it is the same as normal djnago development http://eiry.bitbucket.org/ It is summarized in an easy-to-understand manner.

Create a .gitignore file in the heroku_django directory (Because you don't push unnecessary files)

.gitignore


bin/
include/
lib/
*.pyc

Deploy

When deploying

$ git push heroku master

Error occurred

Error while running '$ python mysite/manage.py collectstatic --noinput'.


 Error that static folder cannot be created on heroku, solved by adding the following 3 lines to setting.py


#### **`setting.py`**
```python

PROJECT_DIR  = os.path.dirname(__file__)
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = os.path.join(PROJECT_DIR, 'static')

Command to create a static folder just below the directory folder

Operation check

Before deploying

$ python manage.py runserver

Or

$ foreman start

Let's check if the app works with.

bootstrap Precautions when using bootstrap Error that is displayed well on runserver but cannot read css well on foreman start http://stackoverflow.com/questions/16170030/django-serves-static-files-with-runserver-but-not-with-foreman Is pinpoint.

$ pip install whitenoise

Is necessary.

Recommended Posts

python + django + scikit-learn + mecab (1) on heroku
python + django + scikit-learn + mecab (2) on heroku
Use Numpy, Scipy, scikit-learn on Heroku
Notes on using MeCab from Python
Don't lose to Ruby! How to run Python (Django) on Heroku
Deploy your Django application on Heroku
Publish DJango page on heroku: Practice
Mecab / Cabocha / KNP on Python + Windows
Python json.loads () returns str on Heroku
Django blog on heroku: login implementation
Periodically run Python on Heroku Scheduler
Deploy Django api on heroku (personal note)
Deploy the Django app on Heroku [Part 2]
Deploy the Django app on Heroku [Part 1]
Redis on Heroku
Python on Windows
Python Django Tutorial (5)
Python Django Tutorial (2)
shimehari on heroku
Python Django Tutorial (8)
Python Django Tutorial (6)
python on mac
LINE heroku python
MeCab from Python
Django Heroku Deploy 2
Python on Windbg
Python Django Tutorial (7)
Python Django Tutorial (1)
Python Django tutorial tutorial
Python Django Tutorial (3)
Python Django Tutorial (4)
A memo of a tutorial on running python on heroku
Publish django project developed in Cloud9 on heroku
How to run MeCab on Ubuntu 18.04 LTS Python
A story about running Python on PHP on Heroku
A memorandum for touching python Flask on heroku
What Python beginners got hooked on with Django
Until you use PhantomJS with Python on Heroku
Install mecab on Marvericks
Django 1.11 started with Python3.6
Deploy a Python 3.6 / Django / Postgres web app on Azure
Python conda on cygwin
Django python web framework
heroku deployment memo (Django)
Install Python on Pidora.
Scraping with Python, posting on TwitterBot, regular execution on Heroku
Install Scrapy on python3
[Heroku] Memo for deploying Python apps using Heroku on Windows [Python]
Celery notes on Django
Run Django on PythonAnywhere
Django Python shift table
Use mecab with Python3
Install Python on Mac
Install Python 3 on Mac
I tried python on heroku for the first time
Install Python3.4 on CentOS 6.6
Deploy a Django application on Google App Engine (Python3)
How to build a Django (python) environment on docker
Try Debian + Python 3.4 + django1.7 ...
Installing pandas on python2.6
Memo of deploying Django × Postgresql on Docker to Heroku