簡體   English   中英

試圖在通過服務(linux)執行的 python 腳本中打開 web 瀏覽器

[英]Trying to open web browser in python script executed via service (linux)

我正在嘗試在 Linux Mint 20.3 上的簡單 python 腳本(只需打開 url)中使用 webbrowser,但它不像在 Z0F4137ED1502B5045D6083AA258B5C42 上那么容易......

webbrowser.get('/usr/bin/google-chrome %s %U --disable-setuid-sandbox --no-sandbox').open('http://google.com')

導致以下錯誤:

ERROR:file_io_posix.cc(144)] open /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq: No such file or directory (2)

ERROR:file_io_posix.cc(144)] open /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq: No such file or directory (2)

ERROR:nacl_helper_linux.cc(307)] NaCl helper process running without a sandbox!

Most likely you need to configure your SUID sandbox correctly

該腳本應該在啟動時通過服務(systemctl)運行,因此我必須使用 --no-sandbox 標志,否則 chromium 不高興。 您知道是否有一種簡單的方法可以修復上面列出的錯誤? 提前致謝

鉻版 97.0.4692.71 64 位

這適用於我的 linux 環境

import webbrowser
webbrowser.open('https://www.google.com')

關於使用 systemctl 啟動腳本,您需要已經啟動了一個窗口系統。 https://unix.stackexchange.com/questions/388837/systemd-run-script-after-gui-is-ready這樣的東西

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM