前提・実現したいこと
出てきているエラーの解決方法がわからないです
寮のメニューを教えてくれるTwitterbotを作ってherokuにpushしてherku run python ****** で実行したときにエラーが出ました
発生している問題・エラーメッセージ
Traceback (most recent call last): File "/app/.heroku/python/lib/python3.6/site-packages/pdf2image/pdf2image.py", line 182, in _page_count proc = Popen(["pdfinfo", pdf_path], stdout=PIPE, stderr=PIPE) File "/app/.heroku/python/lib/python3.6/subprocess.py", line 709, in __init__ restore_signals, start_new_session) File "/app/.heroku/python/lib/python3.6/subprocess.py", line 1344, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: 'pdfinfo': 'pdfinfo' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "downlod.py", line 73, in <module> images = convert_from_path('test.pdf') File "/app/.heroku/python/lib/python3.6/site-packages/pdf2image/pdf2image.py", line 46, in convert_from_path page_count = _page_count(pdf_path, userpw) File "/app/.heroku/python/lib/python3.6/site-packages/pdf2image/pdf2image.py", line 186, in _page_count raise PDFInfoNotInstalledError('Unable to get page count. Is poppler installed and in PATH?') pdf2image.exceptions.PDFInfoNotInstalledError: Unable to get page count. Is poppler installed and in PATH?
該当のソースコード
Python
import urllib.request
import os
import tweepy
from pdf2image import convert_from_path
from PIL import Image
from pytz import timezone
from datetime import datetime
map_x_front = [540,780,1023,1265,1510,1750,1993]
map_x_back = [775,1015,1259,1500,1745,1985,2228]
map_y_a_front = [428,790,1140]
map_y_a_back = [543,840,1190]
map_y_b_front = [615,907,1270]
map_y_b_back = [718,970,1330]
now = datetime.now(timezone('Asia/Tokyo'))
week = now.weekday()
now = str(now)
time = now[11:13]
date = now[8:10]
month = now[5:7]
year = now[0:4]
yera = int(year)
month = int(month)
time = int(time)
date = int(date)
print(now)
if time <= 7:
time_food = 0
elif time <= 12:
time_food=1
else:
time_food=2
if 0>= date - week:
month=month-1
if month-1 == 1 or month-1 == 3 or month -1 == 5 or month -1 == 7 or month -1 ==8 or month -1 == 10 or month-1 == 0:
url_date = date-week+31
elif month-1!=2:
url_date = date-week+30
else:
if year % 4 == 0 and year % 100 != 0:
url_date = date-week+29
elif year % 400 == 0:
url_date = date-week+29
else:
url_date = date-week+28
print(url_date)
if month>=10:
month_str=str(month)
else:
month_str = '0{0}'.format(str(month))
if url_date>=10:
date_str=str(url_date)
else:
date_str = '0{0}'.format(str(url_date))
print(month_str)
print(date_str)
url = 'http://www.tsuyama-ct.ac.jp/imgVer4/hokushinryou/menu/ryoumenu-H31{0}{1}.pdf'.format(month_str,date_str)
savename="test.pdf"
urllib.request.urlretrieve(url,savename)
print("adae")
images = convert_from_path('test.pdf')
print("afa")
images[0].save('test.png','png')
im = Image.open('test.png')
im_crop = im.crop((map_x_front[week],map_y_a_front[time_food],map_x_back[week],map_y_a_back[time_food]))
im_crop2 = im.crop((map_x_front[week],map_y_b_front[time_food],map_x_back[week],map_y_b_back[time_food]))
im_crop.save("test2.png",quality=95)
im_crop2.save("test3.png",quality=95)
im1 = Image.open('test2.png')
im2 = Image.open('test3.png')
dst = Image.new('RGB', (im1.width, im1.height + im2.height))
dst.paste(im1, (0, 0))
dst.paste(im2, (0, im1.height))
dst.save('test4.png')
message=""
print("保存しました")
試したこと
翻訳したりググったりしたのですが、分かりませんでした。
よろしくお願いしますm(_ _)m
あなたの回答
tips
プレビュー