首页 / 安装部署 / Centos7minimal安装playwright和firefox、chromium,终于跑起来了

Centos7minimal安装playwright和firefox、chromium,终于跑起来了

2023-07-18 11:19:30安装部署 阅读 1091

系统环境为CentOS Linux release 7.9.2009 (Core) 最小安装,考虑到playwright的安装需要python3.7+,本次直接选择安装python3.10。Centos7 Python3.10安装部署 之后就开始一波三折的折腾了,最终完成并运行了脚本,模拟浏览器。

1、python3.10安装成功后,就可直接安装playwright

pip3 install playwright -i https://pypi.tuna.tsinghua.edu.cn/simple

2、python3 -m playwright install 将安装模拟的浏览器,firefox、chromium,但在这一步在centos7下会有大量缺少的依赖文件。

解决第一次报错

/usr/local/lib/python3.10/site-packages/playwright/driver/node: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by /usr/local/lib/python3.10/site-packages/playwright/driver/node)
/usr/local/lib/python3.10/site-packages/playwright/driver/node: /lib64/libc.so.6: version `GLIBC_2.25' not found (required by /usr/local/lib/python3.10/site-packages/playwright/driver/node)
/usr/local/lib/python3.10/site-packages/playwright/driver/node: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by /usr/local/lib/python3.10/site-packages/playwright/driver/node)
/usr/local/lib/python3.10/site-packages/playwright/driver/node: /lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by /usr/local/lib/python3.10/site-packages/playwright/driver/node)
/usr/local/lib/python3.10/site-packages/playwright/driver/node: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /usr/local/lib/python3.10/site-packages/playwright/driver/node)
/usr/local/lib/python3.10/site-packages/playwright/driver/node: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /usr/local/lib/python3.10/site-packages/playwright/driver/node)
解决过程
yum install -y centos-release-scl
yum install -y devtoolset-8-gcc*
mv /usr/bin/gcc /usr/bin/gcc-old
ln -s /opt/rh/devtoolset-8/root/bin/gcc /usr/bin/gcc
mv /usr/bin/g++ /usr/bin/g++-old
ln -s /opt/rh/devtoolset-8/root/bin/g++ /usr/bin/g++


wget http://ftp.gnu.org/gnu/make/make-4.3.tar.gz
tar -xzvf make-4.3.tar.gz && cd make-4.3/
./configure  --prefix=/usr/local/make
make && make install
cd /usr/bin/ && mv make make.old
ln -sv /usr/local/make/bin/make /usr/bin/make


yum install -y bison

wget http://ftp.gnu.org/gnu/glibc/glibc-2.28.tar.gz
tar xf glibc-2.28.tar.gz 
cd glibc-2.28/ && mkdir build  && cd build
../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin



Please read the FAQ and the README file and check the following:
- Did you change the gcc specs file (necessary after upgrading from
  Linux libc5)?
- Are there any symbolic links of the form libXXX.so to old libraries?
  Links like libm.so -> libm.so.5 (where libm.so.5 is an old library) are wrong,
  libm.so should point to the newly installed glibc file - and there should be
  only one such link (check e.g. /lib and /usr/lib)
You should restart this script from your build directory after you've
fixed all problems!
Btw. the script doesn't work if you're installing GNU libc not as your
primary library!

出现这个,算完成。

解决第二次报错


python3 -m playwright install 
/usr/local/lib/python3.10/site-packages/playwright/driver/node: /lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by /usr/local/lib/python3.10/site-packages/playwright/driver/node)
/usr/local/lib/python3.10/site-packages/playwright/driver/node: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /usr/local/lib/python3.10/site-packages/playwright/driver/node)
/usr/local/lib/python3.10/site-packages/playwright/driver/node: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /usr/local/lib/python3.10/site-packages/playwright/driver/node).
#解决过程,使用了docker下的libstdc++.so.6.0.28
[root@localhost build]# find / -name "libstdc++.so.*"
/root/vmware-tools/vmware-tools-distrib/lib/lib64/libstdc++.so.6
/root/vmware-tools/vmware-tools-distrib/lib/lib64/libstdc++.so.6/libstdc++.so.6
/root/vmware-tools/vmware-tools-distrib/lib/lib32/libstdc++.so.6
/root/vmware-tools/vmware-tools-distrib/lib/lib32/libstdc++.so.6/libstdc++.so.6
/var/lib/docker/overlay2/124c8f0126e753f480557a2ce60e544cc8dabb278c9eba6d01681f091d266ebb/diff/usr/lib/x86_64-linux-gnu/libstdc++.so.6
/var/lib/docker/overlay2/124c8f0126e753f480557a2ce60e544cc8dabb278c9eba6d01681f091d266ebb/diff/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.28
/var/lib/docker/overlay2/124c8f0126e753f480557a2ce60e544cc8dabb278c9eba6d01681f091d266ebb/diff/usr/share/gdb/auto-load/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.28-gdb.py
/usr/lib/vmware-tools/lib64/libstdc++.so.6
/usr/lib/vmware-tools/lib64/libstdc++.so.6/libstdc++.so.6
/usr/lib/vmware-tools/lib32/libstdc++.so.6
/usr/lib/vmware-tools/lib32/libstdc++.so.6/libstdc++.so.6
/usr/lib64/libstdc++.so.6
/usr/lib64/libstdc++.so.6.0.19
/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.19-gdb.py
/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.19-gdb.pyc
/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.19-gdb.pyo
/usr/local/elasticsearch-6.1.2-old/plugins/x-pack/platform/linux-x86_64/lib/libstdc++.so.6


cd /usr/lib64
mv libstdc++.so.6 libstdc++.so.6.bak
ln -s /var/lib/docker/overlay2/124c8f0126e753f480557a2ce60e544cc8dabb278c9eba6d01681f091d266ebb/diff/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.28 ./libstdc++.so.6


python3 -m playwright install 成功运行


3、运行脚本时还有报错


运行脚本时还报错

playwright._impl._api_types.Error: 
╔══════════════════════════════════════════════════════╗
║ Host system is missing dependencies to run browsers. ║
║ Missing libraries:                                   ║
║     libXcomposite.so.1                               ║
║     libXtst.so.6                                     ║
║     libgtk-3.so.0                                    ║
║     libgdk-3.so.0                                    ║
║     libatk-1.0.so.0                                  ║
║     libcairo-gobject.so.2                            ║
╚══════════════════════════════════════════════════════╝
解决



yum install libXcomposite
yum install libXtst
yum install gtk3
完成!


注意,因为使用的centos系统是没有GUI界面的,所以python脚本一定要设置不显示浏览器,隐藏运行。


browser = await p.firefox.launch(headless=True, )


本文《Centos7minimal安装playwright和firefox、chromium,终于跑起来了》由爱思考吧 isres.com 分享,转载请注明出处。本文网址:https://www.isres.com/bushu/93.html

本站主要收集测评能够节省时间和提升效率的软件工具并分享使用与学习的过程和感受,任何情况下用户都需遵守所使用软件资源的相关协议。与《Centos7minimal安装playwright和firefox、chromium,终于跑起来了》有关的本站文章及资源仅供个人学习交流使用,相关资源请下载后24小时内删除,请勿用于其它用途,因此产生的任何问题由您自行承担。

相关推荐

猜你喜欢