Nuitka icon indicating copy to clipboard operation
Nuitka copied to clipboard

use --plugin-enable=multiprocessing to build cefpython cause an error

Open akeliduo opened this issue 4 years ago • 6 comments

When I use --plugin-enable=multiprocessing to build my code, it causes a error like follow, even I don't use multi-Process at code anymore. (And I need the multiprocess to deal with cefpython)

It's normal to use Command: nuitka --mingw64 --standalone --nofollow-imports --recurse-all --show-memory --show-progress --output-dir=o ownBrowserPopAd.py

But it makes an error by Command:

nuitka --mingw64 --standalone --plugin-enable=multiprocessing --nofollow-imports --recurse-all --show-memory --show-progress --output-dir=o ownBrowserPopAd.py

Error like this: D:\Nuitka_to_Exe\project_to_exe\Data.olllo\mymodule\o\ownBrowserPopAd.dist>ownBrowserPopAd.exe [0702/172126.020:ERROR:main_delegate.cc(710)] Could not load locale pak for en-US [0702/172126.020:ERROR:main_delegate.cc(717)] Could not load cef.pak [0702/172126.020:ERROR:main_delegate.cc(734)] Could not load cef_100_percent.pak [0702/172126.020:ERROR:main_delegate.cc(743)] Could not load cef_200_percent.pak [0702/172126.020:ERROR:main_delegate.cc(753)] Could not load cef_extensions.pak [0702/172126.035:ERROR:content_client.cc(272)] No data resource available for id 101

Could you please give me a sample make command to deal with it?

akeliduo avatar Jul 02 '20 09:07 akeliduo

D:\Nuitka_to_Exe\project_to_exe\Data.olllo\mymodule\o\ownBrowserPopAd.dist>nuitka3 --version 0.6.9rc5 Python: 3.6.6 (v3.6.6:4cf1f54eb7, Jun 27 2018, 03:37:03) [MSC v.1900 64 bit (AMD64)] Executable: d:\program files\python\python.exe OS: Windows Arch: x86_64

akeliduo avatar Jul 02 '20 09:07 akeliduo

And I solve this problem by copy another cefpython3 files into root of project. That's to say I have to use two cefpython3 to run the program... Any good way to solve it ?

akeliduo avatar Jul 03 '20 01:07 akeliduo

Without a reproducer, I can't do anything about it.

kayhayen avatar Jul 20 '20 18:07 kayhayen

  1. code like this,using multiprocessing, Nuitka_cef3.py:
import sys

from cefpython3 import cefpython as cef
from bs4 import BeautifulSoup 

from multiprocessing import Process

class webCef():

    def __init__(self,webctr,siteurl):       
        self.webctr = webctr
        self.siteurl = siteurl      
        cef.Initialize()

    def closeCef(self):
        cef.Shutdown()
    
    def run(self):
        sys.excepthook = cef.ExceptHook  

        self.browser = cef.CreateBrowserSync(url=self.siteurl,window_title='AD')
        #self.browser = cef.CreateBrowser(url="http://olllo.top",window_title='AD')
        self.browser.SetClientHandler(LoadHandler(self.webctr))

        cef.MessageLoop()

        del self.browser
        self.closeCef()

class Visitor(object):
    def __init__(self,webctr):
        self.webctr = webctr
        
    def Visit(self, value):    
        print("This is the HTML source:",value)


class LoadHandler(object):
    def __init__(self,webctr,stop_flag=False):
        self.webctr = webctr
        self.stop_flag = stop_flag

    def OnLoadingStateChange(self,browser,is_loading,**_):
        if not is_loading:
            pass

    def OnLoadEnd(self,browser,frame,http_code):
        if self.stop_flag:
            return
        ''''End Loading and print'''
        self.sv = Visitor(self.webctr)
        frame.GetSource(self.sv)
        print ("OnloadEnd")

    def GetResourceHandler(self, frame, request, **_):
        #print("GetResourceHandler url="+request.GetUrl())
        pass

class webCtr():
    first_time_flag = True 
    def __init__(self,v='olllo_version',u='http://olllo.top'):
        if self.first_time_flag:
            self.mycef = webCef(self,u)
            self.first_time_flag = False

    def run(self):
        self.mycef.run()

def MainPopAD_p():
    print('start Myad_p process')

    ctr = webCtr()
    ctr.run()

def main():
    #Use Process to open cef3
    p_one = Process(target=MainPopAD_p)
    p_one.start()

if __name__ == '__main__':
    main()    

  1. build with nuitka: nuitka --mingw64 --standalone --plugin-enable=multiprocessing --nofollow-imports --recurse-all --show-memory --show-progress --output-dir=o Nuitka_cef3.py

  2. copy bs4 and cefpython3 libs to output dist: 1

  3. run Nuitka_cef3.exe, and the error like this: 2

5.if you copy all the files in directory cefpython3 to dist root, the problem is solved. 3

akeliduo avatar Jul 22 '20 09:07 akeliduo

Thanks for your input, I will look into it.

kayhayen avatar Aug 01 '20 09:08 kayhayen

I managed to run this successfully on Linux, basically just adding a dependency, on Windows however it fails, but I don't see what should be done differently, and the config was added 9 months ago, but the example doesn't work that way. I even checked their pyinstaller hook, and it seems to not make a difference per OS, so not sure what it is about, but it seems files are in fact expected in a different location.

kayhayen avatar Mar 11 '24 15:03 kayhayen