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 doesn't work with pywebview

See original GitHub issue

I’m trying to use the Python module pywebview with Nuitka and I’m not able to to get it to work. I’ve tried to manually copy over the WebBrowserInterop.x86.dll and WebBrowserInterop.x64.dll files from site-packages/webview/lib and still no success. Am I missing something or is Nuitka not linking/including something correctly?

Python, Nuitka, and System Information

0.6.3.1
Python: 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] 
Executable: C:\Python37\python.exe
OS: Windows
Arch: x86_64

main.py

import webview

webview.create_window(title="Hello World!", url="https://www.google.com/")

build.sh

#!/bin/bash

if [ "$1" == "" ]; then
  echo "Usage: $0 -source"
  exit 1
fi

if [ -d "./dist" ]; then
  rm -rf ./dist
  mkdir ./dist
else
  mkdir ./dist
fi

python -m nuitka --show-progress --standalone --recurse-all --experimental=use_pefile --experimental=use_pefile_recurse --experimental=use_pefile_fullrecurse --include-package=webview --output-dir=./dist $1

d="$(sed s/[\.py]//g <<< $1)"

mv ./dist/$d.dist/* ./dist

rm -rf ./dist/$d.build
rm -rf ./dist/$d.dist

./main.exe

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'file:///C:\Users\jason\Projects\scratchpad\webview\dist\Python.Runtime.dll' or one of its dependencies. The system cannot find the file specified.
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
   at System.Reflection.Assembly.LoadFrom(String assemblyFile)
   at clrModule.PyInit_clr()

Any help on this would be great! – Jason.

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
kayhayencommented, Nov 11, 2021

Thanks, those pointers will be good enough.

I think for Nuitka, this ought to be good enough:

    # Unfrozen path
    dll_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'lib', dll_name)
    if os.path.exists(dll_path):
        return dll_path

That should point to webview/util as a folder for the DLLs inside the dist folder, because __file__ is updated correctly with Nuitka. Not sure why PyInstaller needs more help there, but I also don’t care.

0reactions
kayhayencommented, Dec 3, 2021

This is part of the 0.6.18 release.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nuitka compilation error when building on windows
Everything seems to work fine (Pass 1 and Pass 2) but when it comes to compiling the generated C code I keep getting...
Read more >
How do you make a python UI that doesn't look like garbage?
I just stumbled across this kinda old post and just thought I'd recommend pywebview. You don't need to use a server like you...
Read more >
https://nuitka.net/apidoc/classnuitka_1_1plugins_1...
No information is available for this page.
Read more >
【Nuitka】python打包单文件- 代码诠释的世界 - 博客园
This means not a folder, but a compressed executable is created and used. ... Default uses what you are using to run Nuitka,...
Read more >
pynsist Documentation
If you use binary packages, packages compiled for. Python 3.3 won't work with Python 3.4. The other lines make sure it can find...
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