3mora2 / WPP_Whatsapp

WPP_Whatsapp aim of exporting functions from WhatsApp Web to the python, which can be used to support the creation of any interaction, such as customer service, media sending, intelligence recognition based on phrases artificial and many other things, use your imagination
MIT License
57 stars 9 forks source link

ImportError: cannot import name '_api_types' from 'playwright._impl' #27

Closed ZeALer closed 6 months ago

ZeALer commented 6 months ago

When I update to 0.1.5.2 there's an error message.

Traceback (most recent call last):
  File "C:\wa\kirim.py", line 1, in <module>
    from WPP_Whatsapp import Create
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-
packages\WPP_Whatsapp\__init__.py", line 1, in <module>
    from WPP_Whatsapp.api.Whatsapp import Whatsapp
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-
packages\WPP_Whatsapp\api\Whatsapp.py", line 4, in <module>
    from WPP_Whatsapp.api.layers.HostLayer import HostLayer
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-
packages\WPP_Whatsapp\api\layers\HostLayer.py", line 11, in <module>
    from WPP_Whatsapp.PlaywrightSafeThread import ThreadsafeBrowser
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-
packages\WPP_Whatsapp\PlaywrightSafeThread\__init__.py", line 1, in <module>
    from WPP_Whatsapp.PlaywrightSafeThread.browser.threadsafe_browser import Thr
eadsafeBrowser
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-
packages\WPP_Whatsapp\PlaywrightSafeThread\browser\threadsafe_browser.py", line
11, in <module>
    from playwright._impl import _api_types
ImportError: cannot import name '_api_types' from 'playwright._impl' (C:\Users\A
dministrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\playwrigh
t\_impl\__init__.py)

Tried to use older version but still no success.

3mora2 commented 6 months ago

Update Now, it should work

ZeALer commented 6 months ago

New error comes up

Exception in thread Thread-1 (__thread_worker):
Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\threa
ding.py", line 1073, in _bootstrap_inner
    self.run()
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\threa
ding.py", line 1010, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-
packages\WPP_Whatsapp\PlaywrightSafeThread\browser\threadsafe_browser.py", line
335, in __thread_worker
    self.loop.run_until_complete(self.__start_playwright())
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\async
io\base_events.py", line 684, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-
packages\WPP_Whatsapp\PlaywrightSafeThread\browser\threadsafe_browser.py", line
260, in __start_playwright
    self.context = await browser_type.launch_persistent_context(**self._browser_
persistent_option)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-
packages\playwright\async_api\_generated.py", line 14997, in launch_persistent_c
ontext
    await self._impl_obj.launch_persistent_context(
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-
packages\playwright\_impl\_browser_type.py", line 158, in launch_persistent_cont
ext
    from_channel(await self._channel.send("launchPersistentContext", params)),
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-
packages\playwright\_impl\_connection.py", line 62, in send
    return await self._connection.wrap_api_call(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-
packages\playwright\_impl\_connection.py", line 492, in wrap_api_call
    return await cb()
           ^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-
packages\playwright\_impl\_connection.py", line 100, in inner_send
    result = next(iter(done)).result()
             ^^^^^^^^^^^^^^^^^^^^^^^^^
playwright._impl._errors.TargetClosedError: Target page, context or browser has
been closed
Browser logs:

<launching> C:\Users\Administrator\AppData\Local\ms-playwright\chromium-1091\chr
ome-win\chrome.exe --disable-field-trial-config --disable-background-networking
--enable-features=NetworkService,NetworkServiceInProcess --disable-background-ti
mer-throttling --disable-backgrounding-occluded-windows --disable-back-forward-c
ache --disable-breakpad --disable-client-side-phishing-detection --disable-compo
nent-extensions-with-background-pages --disable-component-update --no-default-br
owser-check --disable-default-apps --disable-dev-shm-usage --disable-extensions
--disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,D
estroyProfileOnBrowserClose,MediaRouter,DialMediaRouteProvider,AcceptCHFrame,Aut
oExpandDetailsElement,CertificateTransparencyComponentUpdater,AvoidUnnecessaryBe
foreUnloadCheckSync,Translate,HttpsUpgrades --allow-pre-commit-input --disable-h
ang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable
-prompt-on-repost --disable-renderer-backgrounding --force-color-profile=srgb --
metrics-recording-only --no-first-run --enable-automation --password-store=basic
 --use-mock-keychain --no-service-autorun --export-tagged-pdf --disable-search-e
ngine-choice-screen --no-sandbox --user-data-dir=C:\wa\tokens\Gateway1 --remote-
debugging-pipe about:blank
<launched> pid=848
[pid=848][err] [0105/164402.958:ERROR:main_dll_loader_win.cc(112)] Failed to loa
d Chrome DLL from C:\Users\Administrator\AppData\Local\ms-playwright\chromium-10
91\chrome-win\chrome.dll: The specified procedure could not be found. (0x7F)

I'm using Windows Server 2012 R2. I tried to reinstall WPP_Whatsapp, reinstall and downgrade playwright but still the same error.

3mora2 commented 6 months ago

use firefox and install it creator = Create(session=your_session_name, browser="firefox", install=True)

ZeALer commented 6 months ago

New error comes up


Downloading Firefox 119.0 (playwright build v1429) from https://playwright.azure
edge.net/builds/firefox/1429/firefox-win64.zip
80.5 Mb [====================] 100% 0.0s
Firefox 119.0 (playwright build v1429) downloaded to C:\Users\Administrator\AppD
ata\Local\ms-playwright\firefox-1429
Exception in thread Thread-1 (__thread_worker):
Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\threa
ding.py", line 1073, in _bootstrap_inner
    self.run()
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\threa
ding.py", line 1010, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-
packages\WPP_Whatsapp\PlaywrightSafeThread\browser\threadsafe_browser.py", line
335, in __thread_worker
    self.loop.run_until_complete(self.__start_playwright())
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\async
io\base_events.py", line 684, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-
packages\WPP_Whatsapp\PlaywrightSafeThread\browser\threadsafe_browser.py", line
260, in __start_playwright
    self.context = await browser_type.launch_persistent_context(**self._browser_
persistent_option)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-
packages\playwright\async_api\_generated.py", line 14997, in launch_persistent_c
ontext
    await self._impl_obj.launch_persistent_context(
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-
packages\playwright\_impl\_browser_type.py", line 158, in launch_persistent_cont
ext
    from_channel(await self._channel.send("launchPersistentContext", params)),
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-
packages\playwright\_impl\_connection.py", line 62, in send
    return await self._connection.wrap_api_call(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-
packages\playwright\_impl\_connection.py", line 492, in wrap_api_call
    return await cb()
           ^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-
packages\playwright\_impl\_connection.py", line 100, in inner_send
    result = next(iter(done)).result()
             ^^^^^^^^^^^^^^^^^^^^^^^^^
playwright._impl._errors.Error: spawn UNKNOWN
ZeALer commented 6 months ago

There's something wrong with my firefox. Using Edge and run smoothly

creator = Create(session=your_session_name, browser="msedge", install=True)

3mora2 commented 6 months ago

Error related to playwright when try launch profile saved before or create new one