1
我正嘗試在Flask中使用pdfkit生成PDF。 pdfkit在本地工作正常,但是當我在Google App Engine中使用它時,會引發以下錯誤。在Google App Engine中使用pdfkit生成PDF引發了Popen的AttributeError
Traceback (most recent call last):
File "C:\Python27\flaskapp\flask\app.py", line 1687, in wsgi_app
response = self.full_dispatch_request()
File "C:\Python27\flaskapp\flask\app.py", line 1360, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Python27\flaskapp\flask\app.py", line 1358, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Python27\flaskapp\flask\app.py", line 1344, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "C:\Python27\flaskapp\main.py", line 17, in yout
pdf = pdfkit.from_string(my_string,False , configuration=config)
File "C:\Python27\flaskapp\pdfkit\api.py", line 68, in from_string
return r.to_pdf(output_path)
File "C:\Python27\flaskapp\pdfkit\pdfkit.py", line 92, in to_pdf
result = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
AttributeError: 'module' object has no attribute 'Popen'
from flask import Flask, make_response, request, render_template
import pdfkit
path_wkthmltopdf = r'C:\Python27\flaskapp\wkhtmltopdf\bin\wkhtmltopdf.exe'
config = pdfkit.configuration(wkhtmltopdf=path_wkthmltopdf)
app = Flask(__name__)
@app.route('/pdf', methods=['POST', 'GET'])
def pdf():
if request.method == 'POST':
my_string = request.form['text11']
pdf = pdfkit.from_string(my_string, False, configuration=config)
response = make_response(pdf)
response.headers['Content-Type'] = 'application/pdf'
response.headers['Content-Disposition'] = 'inline; filename=out.pdf'
return response
return render_template('pdff.html')
任何解決方案?............................................ ......... – user6948460
請勿使用App Engine? –
App Engine沒有什麼特別的問題。您可以在「靈活」環境中使用任何你想要的東西。 – bigblind