基于centos 7 x86_64 安装playwright框架

一. python 3 安装

     playwright 要求python版本必须是在3.8及以上,推荐安装3.8~3.9的版本,可以很大一部分工作量,因为python 10(包括10)不在支持tls/ssl ,在安装时必须自己单独安装openssl进行代替,而升级openssl需要先升级gcc g++ 版本,然后搭建编译环境,最后生成openssl包,巨麻烦,推荐直接下载openssl rpm包进行离线安装,直接跳过编译,我看到网上很多同学被各种折磨.

 

自行安装python 3.8~3.9 版本不在赘述。

 

二.安装playwright 遇到的问题

playwright 底层打开浏览器驱动基于nodejs 框架,所以需要先安装nodejs

[root@VM-1-62-tencentos /opt/metersphere/data/custom_script]# node --version
v18.17.1
[root@VM-1-62-tencentos /opt/metersphere/data/custom_script]# npm --version
9.6.7
[root@VM-1-62-tencentos /opt/metersphere/data/custom_script]#

 

[root@VM-1-62-os]#  playwright install
node: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by node)
node: /lib64/libc.so.6: version `GLIBC_2.25' not found (required by node)
node: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by node)

 

缺少依赖,需要下载离线包到本地进行编译安装,注意:执行make -j 4 & make install 后,会报错,可以完全忽略,不影响使用.

解决办法参考地址:

https://blog.csdn.net/weixin_44051608/article/details/109514140#:~:text=%E5%AE%89%E8%A3%85glibc-2.17.tar.gz%EF%BC%9A%20cd%20%2Fopt%20wget%20http%3A%2F%2Fftp.gnu.org%2Fpub%2Fgnu%2Fglibc%2Fglibc-2.17.tar.gz%20tar%20-zxvf%20glibc-2.17.tar.gz,--enable-add-ons%20--with-headers%3D%2Fusr%2Finclude%20--with-binutils%20%3D%2Fusr%2Fbin%20make%20%26%26%20make%20install

[root@VM-1-62-os]#  playwright install
playwright._impl._api_types.Error: ╔══════════════════════════════════════════════════════╗

║ Host system is missing dependencies to run browsers. ║

║ Missing libraries: ║

libatk-bridge-2.0.so.0 
libxkbcommon.so.0 
libatspi.so.0

╚══════════════════════════════════════════════════════╝

表示缺少依赖,执行如下命令进行安装.

yum install at-spi2-atk -y  # 对应libatk-bridge-2.0.so.0 

yum install libxkbcommon # 对应libxkbcommon.so.0 

yum install -y libatspi.so.0 #对应libatspi.so.0

 

解决办法参考地址:

https://www.cnblogs.com/dingnosakura/p/17474864.html

 

posted @ 2024-01-10 11:11  Eillot  阅读(905)  评论(0编辑  收藏  举报