playwright部署SUSE12填坑

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

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

  • 會(huì)出現(xiàn)各種問(wèn)題,比如:
/home/kyo/桌面/Python-3.8.17/Modules/_ctypes/_ctypes.c:107:17: 致命錯(cuò)誤:ffi.h:沒(méi)有那個(gè)文件或目錄
 #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)

  • 此時(shí),如果直接pip install playwright,當(dāng)前會(huì)安裝1.35版本,后續(xù)運(yùn)行,可能會(huì)出現(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!

此時(shí),解決方案有兩個(gè)(后者簡(jiǎn)單直接):

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

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

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

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

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

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

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容