Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x wkhtmltopdf不';使用(Flask)pdfkit和wkhtmltopdf在heroku python应用程序中部署时无法工作_Python 3.x_Heroku_Wkhtmltopdf_Pdfkit_Python Pdfkit - Fatal编程技术网

Python 3.x wkhtmltopdf不';使用(Flask)pdfkit和wkhtmltopdf在heroku python应用程序中部署时无法工作

Python 3.x wkhtmltopdf不';使用(Flask)pdfkit和wkhtmltopdf在heroku python应用程序中部署时无法工作,python-3.x,heroku,wkhtmltopdf,pdfkit,python-pdfkit,Python 3.x,Heroku,Wkhtmltopdf,Pdfkit,Python Pdfkit,我正在用python将HTML文件转换为pdf文件,并将这些pdf文件附加到邮件中并进行处理 我已经安装了pdfkit(0.6.1)、wkhtmltopdf(0.2)以及用于windows的wkhtmltopdf。并添加了wkhtmltopdf bin路径。它在我的本地系统中工作,没有任何问题。这是我的代码 url="" PDF = pdfkit.from_url(url, False) result= SendPDFtomail(PDF) return result 当我试图通过添加w

我正在用python将HTML文件转换为pdf文件,并将这些pdf文件附加到邮件中并进行处理

  • 我已经安装了pdfkit(0.6.1)、wkhtmltopdf(0.2)以及用于windows的wkhtmltopdf。并添加了wkhtmltopdf bin路径。它在我的本地系统中工作,没有任何问题。这是我的代码

    url=""
    PDF = pdfkit.from_url(url, False)
    result= SendPDFtomail(PDF)
    return result 
    
  • 当我试图通过添加wkhtmltopdf的buildpack和我的应用程序的buildpack将相同的代码推入heroku时

      1. heroku/python
      2. https://github.com/dscout/wkhtmltopdf-buildpack.git
    
  • 当我把我的构建推给heroku时

       git push heroku master
       Counting objects: 3, done.
       Delta compression using up to 4 threads.
       Compressing objects: 100% (3/3), done.
       Writing objects: 100% (3/3), 336 bytes | 84.00 KiB/s, done.
       Total 3 (delta 2), reused 0 (delta 0)
       remote: Compressing source files... done.
       remote: Building source:
       remote:
       remote: -----> Python app detected
       remote:  !     The latest version of Python 3.6 is python-3.6.6 (you 
       are using python-3.6.4, which is unsupported).
       remote:  !     We recommend upgrading by specifying the latest version 
       (python-3.6.6).
       remote:        Learn More: 
       https://devcenter.heroku.com/articles/python-runtimes
       remote: -----> Installing requirements with pip
       remote:
       remote: -----> wkhtmltopdf app detected
       remote: -----> Moving wkhtmltopdf binaries to /app/bin
       remote: -----> Discovering process types
       remote:        Procfile declares types -> web
       remote:
       remote: -----> Compressing...
       remote:        Done: 103.8M
       remote: -----> Launching...
       remote:        Released v19
       remote:        https://XXXXXXX.herokuapp.com/ deployed to 
       Heroku
       remote:
       remote: Verifying deploy... done.
    
我的应用程序部署时没有任何问题,当我在Heroku中运行代码时,我得到了错误

      Exception :No wkhtmltopdf executable found: "b''"
      If this file exists please check that this process can read it. 
      Otherwise please install wkhtmltopdf - 
      https://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf
这与我没有将wkhtmltopdf路径添加到系统时收到的错误相同,正如我们在build
中将wkhtmltopdf二进制文件移动到/app/bin
中所看到的,我如何使我的Heroku配置到此wkhtmltopdf二进制路径?我们如何在Heroku中使用配置变量来实现这一点

我试过这个,但没能得到。无论我在哪里搜索ruby的解决方案,我们都需要配置gem文件,我怎样才能在python中实现呢

过去两天我一直在做,请帮帮我

提前谢谢


Meghana Goud

我现在正在使用OSX和heroku部署我的flask应用程序。 部署时,heroku wkhtmltopdf二进制文件位于./bin/wkhtmltopdf中。 所以我写了这段代码来处理这个问题

if (platform.system() == 'Darwin'):
    config = pdfkit.configuration()
else:
    config = pdfkit.configuration(wkhtmltopdf='./bin/wkhtmltopdf')

您提到您在本地计算机上设置了bin路径,但我看不出您在哪里这样做。在python中,您可以在从url调用之前在python中提供它,并避免使用以下全局环境:pdfkit.configuration(wkhtmltopdf=r'D:\example\path\here\wkhtmltopdf.exe')