-2

New to Google App Engine. Building entirely using Google Cloud Shell - mainly learning the platform before doing serious development. Completed all possible future requirements, except for showing graphs on webpage and downloading PDF. This question is about downloading PDF

I create a new folder PDF

Under appengine_config.py I add:

vendor.add('pdf')

I run command:

pip install -t pdf/ xhtml2pdf

I get an error message:

ipython 5.10.0 has requirement prompt-toolkit<2.0.0,>=1.0.4, but you'll have prompt-toolkit 2.0.10 which is incompatible.

I create a Class PDFHandler.py with code starting as:

from io import StringIO
from xhtml2pdf import pisa

I write rest of the code and run Application using python3 main.py, I get error as:

ModuleNotFoundError: No module named 'xhtml2pdf'

What is it that I am missing? Is there a better way to have ability to download custom PDF?

mmgae7394
  • 31
  • 1
  • 3
  • For the requirement from ipython on prompt-toolkit version, there is a conflict with requirement from mssql-cli 1.0.0 has requirement prompt-toolkit<2.1.0,>=2.0.0. So I ignored that portion which may be contributing? – mmgae7394 Aug 31 '20 at 22:54

1 Answers1

0

I was able to reproduce your issue by running pip install -t pdf/ xhtml2pdf from the Cloud Shell, as the following error shows up:

Successfully built xhtml2pdf pyPdf2 ipython 5.10.0 has requirement prompt-toolkit<2.0.0,>=1.0.4, but you'll have prompt-toolkit 2.0.10 which is incompatible. Installing collected packages: webencodings, six, html5lib, pyPdf2, Pillow, reportlab, xhtml2pdf ...

If you follow this documentation to create a virtual environment on your Cloud Shell and use the following command pip3 install -t pdf/ xhtml2pdf --upgrade to install the required dependency (or in general create a requirements.txt file, add the necessary dependencies there and run pip3 install -r requirements.txt) you shouldn't see the prompt described above anymore.

In an additional note I wouldn't recommend using the Cloud Shell as a development environment, as it is a tool meant for rapid prototyping and testing.

In general please refer to the following documentation to setup a Python development environment.

And if your application requires some PDF handling I would recommend you exploring the use of App Engine Flexible environment to install the specific dependencies that are required for your PDF processing in a separate service that can be called by your main application via HTTP. Find more information about this here.

Daniel Ocando
  • 3,554
  • 2
  • 11
  • 19