How to Install wkhtmltopdf for the Python pdfkit Library?

This topic was automatically generated from Slack. You can find the original thread here.

Hello there, is there a way to install wkhtmltopdf to make the pdfkit Python library work?
This is the error I’m getting:

Hi , You can use package from Pypip in Pipedream Python code step. You can refer to this doc for more information: Python

Hi , thank you for the suggestion. I’ll take a look.

I tried importing the wkhtmltopdf package, but I keep getting this error.

How can I solve it?

ModuleNotFoundError
No module named 'main'

DETAILS
Traceback (most recent call last):

  File "/nano-py/server.py", line 71, in <module>
    worker.load()

  File "/nano-py/pipedream/worker.py", line 100, in load
    self.step_modules[cell["id"]] = importlib.import_module(cell["importPath"])

  File "/var/lang/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)

  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import

  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load

  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked

  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked

  File "<frozen importlib._bootstrap_external>", line 850, in exec_module

  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed

  File "/tmp/__pdg__/dist/code/2e79f01d5c1145c447ececac742edca16f7b9e30ff3cf88b41b5d319b7bb168c/code.py", line 2, in <module>
    import wkhtmltopdf

  File "/tmp/__pdg__/dist/python/wkhtmltopdf/__init__.py", line 1, in <module>
    from main import WKhtmlToPdf, wkhtmltopdf

ModuleNotFoundError: No module named 'main'

I saw you online. How can I correctly import the wkhtmltopdf package from PyPI?

Hi Cagri, please refer to the docs that Leo provided: Python

There’s a section about importing packages using a special comment system that might prove to be helpful.

But please note, some PyPi packages rely on external binaries or architectures may not be compatible with Pipedream Python code steps.

I tried that as well, but I keep getting the error above.
This is how I did it at the top of the Python code:

# pipedream add-package wkhtmltopdf

import wkhtmltopdf

Hi , then I afraid the library you are using is not compatible with Pipedream. Would you mind trying to use other library that can do the same thing?

Also, please consider reporting this issue to our public issue tracker here: Sign in to GitHub · GitHub

Some Python packages are not compatible at this time unfortunately, due to the limitations I described before.

Hi , I’m using the pdfkit library, which requires wkhtmltopdf to work. So I cannot make my code work right now.

@U02SX7ETBFB, of course, let me report it here.

I just created this issue: