question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Nuitka Convert Error With Weasyprint in Python Code

See original GitHub issue

I am trying to compile executable file from Python code which uses WeasyPrint for PDF conversion using Nuitka but giving error.

I have installed MinGW64 for C compiler under “c:\MinGW64”.

python -m nuitka --follow-imports --standalone --mingw64 websense-url-checker.py

After running the code it gives the following warning.

Nuitka:WARNING:Use '--plugin-enable=pylint-warnings' for: Understand PyLint/PyDev annotations for warnings.

Nuitka:WARNING:Unresolved '__import__' call at 'C:\Users\[USER-NAME]\DOCUME~1\TEST-
P~1\WEBSEN~1\venv\lib\site-packages\PIL\Image.py:432' may require use of '--incl
ude-plugin-directory' or '--include-plugin-files'.

Nuitka:WARNING:Unresolved '__import__' call at 'C:\Users\[USER-NAME]\DOCUME~1\TEST-
P~1\WEBSEN~1\venv\lib\site-packages\cffi\verifier.py:151' may require use of '--
include-plugin-directory' or '--include-plugin-files'.

Nuitka:WARNING:Unresolved '__import__' call at 'C:\Users\[USER-NAME]\DOCUME~1\TEST-
P~1\WEBSEN~1\venv\lib\site-packages\cx_Freeze\hooks.py:468' may require use of '
--include-plugin-directory' or '--include-plugin-files'.

Nuitka:WARNING:Unresolved '__import__' call at 'C:\Users\[USER-NAME]\DOCUME~1\TEST-
P~1\WEBSEN~1\venv\lib\site-packages\defusedxml\common.py:83' may require use of
'--include-plugin-directory' or '--include-plugin-files'.

Nuitka:WARNING:Unresolved '__import__' call at 'C:\Users\[USER-NAME]\DOCUME~1\TEST-
P~1\WEBSEN~1\venv\lib\site-packages\jinja2\loaders.py:472' may require use of '-
-include-plugin-directory' or '--include-plugin-files'.

Nuitka:WARNING:Unresolved '__import__' call at 'C:\Users\[USER-NAME]\DOCUME~1\TEST-
P~1\WEBSEN~1\venv\lib\site-packages\jinja2\utils.py:142' may require use of '--i
nclude-plugin-directory' or '--include-plugin-files'.

Nuitka:WARNING:Unresolved '__import__' call at 'C:\Users\[USER-NAME]\DOCUME~1\TEST-
P~1\WEBSEN~1\venv\lib\site-packages\jinja2\utils.py:143' may require use of '--i
nclude-plugin-directory' or '--include-plugin-files'.

Nuitka:WARNING:Unresolved '__import__' call at 'C:\Users\[USER-NAME]\DOCUME~1\TEST-
P~1\WEBSEN~1\venv\lib\site-packages\requests\packages.py:7' may require use of '
--include-plugin-directory' or '--include-plugin-files'.

It generates executable though but running the exe it gives the following.

websense-url-checker.dist\websense-url-checker.exe

Traceback (most recent call last):
  File "C:\Users\[USER-NAME]\Documents\test-python\websense-url-checker\websense-url-checker.dist\websense-url-checker.py", line 3, in <module>
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 668, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 638, in _load_backward_compatible
  File "C:\Users\[USER-NAME]\Documents\test-python\websense-url-checker\websense-url-checker.dist\weasyprint\__init__.py", line 20, in <module weasyprint>
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 668, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 638, in _load_backward_compatible
  File "C:\Users\[USER-NAME]\Documents\test-python\websense-url-checker\websense-url-checker.dist\cssselect2\__init__.py", line 20, in <module cssselect2>
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 668, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 638, in _load_backward_compatible
  File "C:\Users\[USER-NAME]\Documents\test-python\websense-url-checker\websense-url-checker.dist\cssselect2\compiler.py", line 7, in <module cssselect2.compiler>
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 668, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 638, in _load_backward_compatible
  File "C:\Users\[USER-NAME]\Documents\test-python\websense-url-checker\websense-url-checker.dist\tinycss2\__init__.py", line 10, in <module tinycss2>
  File "C:\Users\[USER-NAME]\Documents\test-python\websense-url-checker\websense-url-checker.dist\pathlib.py", line 1206, in read_text
  File "C:\Users\[USER-NAME]\Documents\test-python\websense-url-checker\websense-url-checker.dist\pathlib.py", line 1193, in open
  File "C:\Users\[USER-NAME]\Documents\test-python\websense-url-checker\websense-url-checker.dist\pathlib.py", line 1046, in _opener
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\[USER-NAME]\\Documents\\test-python\\websense-url-checker\\websense-url-checker.dist\\tinycss2\\VERSION'

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
JorjMcKiecommented, Sep 27, 2019

Sorry for the tardiness of my reaction - just recovered from severe internet outages. Can you please provide an as small as possible snippet to reproduce this? Ideally just the imports or similar. Looks like the standard situation of adjusting some implicit imports and missing data files …

0reactions
kayhayencommented, Dec 15, 2021

Can you please raise another issue and fill out the issue template if this still persists. I do not understand this issue as it is.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nuitka-chat/community - Gitter
Hi @all I am using Nuitka to convert Python program which is using WeasyPrint for creating PDF. ... But running the exe it...
Read more >
Error while creating a python file executable - nuitka
I have been using nuitka to compile python to create executable so that I do not have to share the source code with...
Read more >
What is the best way to create pdf files with Python? - Quora
Use a library called pdfkit. Use a library called waesyprint. You can also convert a Dataframe to HTML and then use it to...
Read more >
[Example code]-Can __rrshift__ take more than one argument?
You can probably modify that by hacking the heck of Python's grammar with the ast module, but that won't be Python anymore.
Read more >
Unionline - 博客园
A curated list of awesome Python frameworks, libraries, software and resources ... black - The uncompromising Python code formatter.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found