playwright部署SUSE12填坑

与SUSE12的服务器部署的那些事。
-2、虚拟机安装,参考: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工具,可以安装一些基础的库,可能会用到。

0、部署python3,去官网python.org下载python,然后参考:SUSE12 离线安装python - 走看看 (zoukankan.com)安装python,但是,不会那么顺利。

  • 会出现各种问题,比如:
/home/kyo/桌面/Python-3.8.17/Modules/_ctypes/_ctypes.c:107:17: 致命错误:ffi.h:没有那个文件或目录
 #include 
                 ^
编译中断。

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包的区别 - 知乎 (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的话,会提示SSL之类的问题,安装库指定的仓库只能是http的。参考这篇,使用阿里云解决 :(3条消息) 【日常踩坑】解决 pip 安装第三方包时因 SSL 报错_pip ssl_ywang_wnlo的博客-CSDN博客

  • 此时,如果直接pip install playwright,当前会安装1.35版本,后续运行,可能会出现需要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  
    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,会出现覆盖本地GLIBC的问题,也可以换个路径装,但是装完之后,不知道后续怎么处理(参考:OSError: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by xxx.so) ——升级GLIBC并解决系统错误 - 知乎 (zhihu.com)
    ),其中:
  • 更新glibc前,需要更新gcc和make,会出现gcc和make版本过老的问题,需要升级gcc和make。(更新gcc和make的内容参考:(3条消息) These critical programs are missing or too old: make compiler_Dan淡淡的心的博客-CSDN博客
    -----------(3条消息) configure: error: Building GCC requires GMP 4.2+, MPFR 3.1.0+ and MPC 0.8.0+._请叫我大虾的博客-CSDN博客

推荐从阿里云下载相应的代码:gnu-make安装包下载_开源镜像站-阿里云 (aliyun.com)

  1. 降级playwright,由于本地开发的时候使用的1.35版本的playwright codegen,生成的代码存在一些新版本的api。因此,降级到对应api出现的版本,这里选择的是1.27。

最后的运行阶段:
1、安装playwright支持版本的chromium(CNPM Binaries Mirror (npmmirror.com)
自己找对应自己需要的版本。)
参考:Linux Zip文件解压教程|极客笔记 (deepinout.com)

2、在运行playwright的相关python代码的时候,指定execution_path,来指定浏览器的运行路径,使用headless来指定浏览器是否以非GUI方式运行

本地安装参考:python+playwright 学习-42 离线安装 playwright 环境 - 上海-悠悠 - 博客园 (cnblogs.com)

你可能感兴趣的:(playwright部署SUSE12填坑)