playwright部署SUSE12填坑

與SUSE12的服務(wù)器部署的那些事。
-2、虛擬機(jī)安裝,參考:suse12 sp4,sp5 鏡像資源分享 | 程序園 (program-park.top)
-1、下個免費版的moba,夠用了,方便上傳下載文件,只因我這邊vmware的tool沒有生效。MobaXterm Xserver with SSH, telnet, RDP, VNC and X11 - Home Edition (mobatek.net)
插曲:YaST Software Management - openSUSE Wiki SUSE有一個Yast工具,可以安裝一些基礎(chǔ)的庫,可能會用到。

0、部署python3,去官網(wǎng)python.org下載python,然后參考:SUSE12 離線安裝python - 走看看 (zoukankan.com)安裝python,但是,不會那么順利。

  • 會出現(xiàn)各種問題,比如:
/home/kyo/桌面/Python-3.8.17/Modules/_ctypes/_ctypes.c:107:17: 致命錯誤:ffi.h:沒有那個文件或目錄
 #include <ffi.h>
                 ^
編譯中斷。

Python build finished successfully!
The necessary bits to build these optional modules were not found:
_bz2                  _curses               _curses_panel
_dbm                  _gdbm                 _hashlib
_lzma                 _sqlite3              _ssl
_tkinter              _uuid                 readline
To find the necessary bits, look in setup.py in detect_modules() for the module's name.


The following modules found by detect_modules() in setup.py, have been
built by the Makefile instead, as configured by the Setup files:
_abc                  atexit                pwd
time


Failed to build these modules:
_ctypes


Could not build the ssl module!
Python requires an OpenSSL 1.0.2 or 1.1 compatible libssl with X509_VERIFY_PARAM_set1_host().
LibreSSL 2.6.4 and earlier do not provide the necessary APIs, https://github.com/libressl-portable/portable/issues/38

解決方法:使用rpm安裝libffi4和libffi:suse官方 devel:gcc / libffi4 (opensuse.org)可選libffi安裝
另附:zlib下載鏈接:http://www.zlib.net/fossils/zlib-1.2.11.tar.gz
參考:linux 中 devel包 和 非devel包的區(qū)別 - 知乎 (zhihu.com)

(3條消息) ppc64,ppc64le,ARM,AMD,X86,i386,x86_64(AMD64),AArch64的概念_Lay_Nobody的博客-CSDN博客

(3條消息) CentOS7 離線安裝 Python_libffi-devel離線安裝_v空空的博客-CSDN博客

RPM包安裝 · Linux教程 · 看云 (kancloud.cn)

  • 此時,如果直接pip install playwright,當(dāng)前會安裝1.35版本,后續(xù)運行,可能會出現(xiàn)需要GLIBC的某些版本,比如:
/home/kyo/.local/lib/python3.8/site-packages/playwright/driver/node: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by /home/kyo/.local/lib/python3.8/site-packages/playwright/driver/node) 
/home/kyo/.local/lib/python3.8/site-packages/playwright/driver/node: /lib64/libc.so.6: version `GLIBC_2.25' not found (required by /home/kyo/.local/lib/python3.8/site-packages/playwright/driver/node) 
/home/kyo/.local/lib/python3.8/site-packages/playwright/driver/node: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by /home/kyo/.local/lib/python3.8/site-packages/playwright/driver/node) 
Traceback (most recent call last): 
  File "test.py", line 4, in <module> 
    with sync_api.sync_playwright() as p: 
  File "/home/kyo/.local/lib/python3.8/site-packages/playwright/sync_api/_context_manager.py", line 94, in __enter__ 
    playwright = self._playwright 
AttributeError: 'PlaywrightContextManager' object has no attribute '_playwright' 
Task was destroyed but it is pending!

此時,解決方案有兩個(后者簡單直接):

  1. 此時如果直接升級GLIBC,會出現(xiàn)覆蓋本地GLIBC的問題,也可以換個路徑裝,但是裝完之后,不知道后續(xù)怎么處理(參考:OSError: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by xxx.so) ——升級GLIBC并解決系統(tǒng)錯誤 - 知乎 (zhihu.com)
    ),其中:

推薦從阿里云下載相應(yīng)的代碼:gnu-make安裝包下載_開源鏡像站-阿里云 (aliyun.com)

  1. 降級playwright,由于本地開發(fā)的時候使用的1.35版本的playwright codegen,生成的代碼存在一些新版本的api。因此,降級到對應(yīng)api出現(xiàn)的版本,這里選擇的是1.27。

最后的運行階段:
1、安裝playwright支持版本的chromium(CNPM Binaries Mirror (npmmirror.com)
自己找對應(yīng)自己需要的版本。)
參考:Linux Zip文件解壓教程|極客筆記 (deepinout.com)

2、在運行playwright的相關(guān)python代碼的時候,指定execution_path,來指定瀏覽器的運行路徑,使用headless來指定瀏覽器是否以非GUI方式運行

本地安裝參考:python+playwright 學(xué)習(xí)-42 離線安裝 playwright 環(huán)境 - 上海-悠悠 - 博客園 (cnblogs.com)

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容