pyscreenshot.err.FailedBackendError: All backends failed
pyscreenshot.err.FailedBackendError: All backends failed
我是 python 网络应用的新手。
我正在 python任何地方使用来托管我的网络应用程序。
Pyscreenshot 通过 pip3.8 install --user Pillow pyscreenshot
安装
我正在使用 ajax 在单击按钮时调用一个函数,该函数使用 pyscreenshot 截取屏幕截图并将其作为图像文件存储在给定路径上。
本地环境运行一切正常(manjaro,python3.8)
然而,当我在 python 任何地方 运行 相同的代码时,我在网站上遇到未处理的异常。
在错误日志中,我看到以下内容:
2020-06-16 11:30:09,927: Exception on /takess [GET]
Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/flask/app.py", line 2446, in wsgi_app
response = self.full_dispatch_request()
File "/usr/lib/python3.8/site-packages/flask/app.py", line 1951, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/lib/python3.8/site-packages/flask/app.py", line 1820, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/usr/lib/python3.8/site-packages/flask/app.py", line 1949, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/lib/python3.8/site-packages/flask/app.py", line 1935, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/Muhammadpen/mysite/flask_app.py", line 12, in takess
im = ImageGrab.grab()
File "/home/Muhammadpen/.local/lib/python3.8/site-packages/pyscreenshot/__init__.py", line 31, in grab
return backend_grab(backend, bbox, childprocess)
File "/home/Muhammadpen/.local/lib/python3.8/site-packages/pyscreenshot/loader.py", line 147, in backend_grab
return auto(bbox, childprocess)
File "/home/Muhammadpen/.local/lib/python3.8/site-packages/pyscreenshot/loader.py", line 127, in auto
raise FailedBackendError(msg)
pyscreenshot.err.FailedBackendError: All backends failed!
代码如下:
Index.html
<!DOCTYPE html>
<html>
<head>
<title>Inspector jitsi</title>
</head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type=text/javascript>
$(function() {
$('a#ssbutton').bind('click', function() {
$.getJSON('/takess',
function(data) {
//do nothing
});
return false;
});
});
</script>
<body>
<iframe
src="https://meet.jit.si/"
style="height: 900px; width: 100%;"
></iframe>
<div class='container'>
<form>
<a href=# id=ssbutton><button class='btn btn-default'>Take screenshot</button></a>
</form>
</div>
</body>
<style>
html,
body {
overflow: hidden;
margin: 0px;
padding: 0px;
}
form{
position: absolute;
left: 50%;
z-index: 0;
}
</style>
</html>
app.py:
from flask import Flask, render_template
import pyscreenshot as ImageGrab
app = Flask(__name__)
@app.route('/')
def index():
return render_template("index.html")
@app.route('/takess')
def takess():
im = ImageGrab.grab()
im.save(r'/home/Muhammadpen/mysite/ss1.png')
# im.save(r'/home/pen/Documents/ss1.png')
if __name__ == "__main__":
app.run(debug=True)
我找不到关于此的任何相关信息或修复,因此我们将不胜感激。泰!
PyScreenshot 用于截取桌面应用程序的屏幕截图。由于您的应用程序 运行 在服务器上,因此没有什么可以截图的。
如果您打算截取用户浏览器的屏幕截图,you would use frontend tooling,它在浏览器中运行,而不是服务器端工具。
我是 python 网络应用的新手。
我正在 python任何地方使用来托管我的网络应用程序。
Pyscreenshot 通过 pip3.8 install --user Pillow pyscreenshot
我正在使用 ajax 在单击按钮时调用一个函数,该函数使用 pyscreenshot 截取屏幕截图并将其作为图像文件存储在给定路径上。
本地环境运行一切正常(manjaro,python3.8)
然而,当我在 python 任何地方 运行 相同的代码时,我在网站上遇到未处理的异常。 在错误日志中,我看到以下内容:
2020-06-16 11:30:09,927: Exception on /takess [GET]
Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/flask/app.py", line 2446, in wsgi_app
response = self.full_dispatch_request()
File "/usr/lib/python3.8/site-packages/flask/app.py", line 1951, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/lib/python3.8/site-packages/flask/app.py", line 1820, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/usr/lib/python3.8/site-packages/flask/app.py", line 1949, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/lib/python3.8/site-packages/flask/app.py", line 1935, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/Muhammadpen/mysite/flask_app.py", line 12, in takess
im = ImageGrab.grab()
File "/home/Muhammadpen/.local/lib/python3.8/site-packages/pyscreenshot/__init__.py", line 31, in grab
return backend_grab(backend, bbox, childprocess)
File "/home/Muhammadpen/.local/lib/python3.8/site-packages/pyscreenshot/loader.py", line 147, in backend_grab
return auto(bbox, childprocess)
File "/home/Muhammadpen/.local/lib/python3.8/site-packages/pyscreenshot/loader.py", line 127, in auto
raise FailedBackendError(msg)
pyscreenshot.err.FailedBackendError: All backends failed!
代码如下:
Index.html
<!DOCTYPE html>
<html>
<head>
<title>Inspector jitsi</title>
</head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type=text/javascript>
$(function() {
$('a#ssbutton').bind('click', function() {
$.getJSON('/takess',
function(data) {
//do nothing
});
return false;
});
});
</script>
<body>
<iframe
src="https://meet.jit.si/"
style="height: 900px; width: 100%;"
></iframe>
<div class='container'>
<form>
<a href=# id=ssbutton><button class='btn btn-default'>Take screenshot</button></a>
</form>
</div>
</body>
<style>
html,
body {
overflow: hidden;
margin: 0px;
padding: 0px;
}
form{
position: absolute;
left: 50%;
z-index: 0;
}
</style>
</html>
app.py:
from flask import Flask, render_template
import pyscreenshot as ImageGrab
app = Flask(__name__)
@app.route('/')
def index():
return render_template("index.html")
@app.route('/takess')
def takess():
im = ImageGrab.grab()
im.save(r'/home/Muhammadpen/mysite/ss1.png')
# im.save(r'/home/pen/Documents/ss1.png')
if __name__ == "__main__":
app.run(debug=True)
我找不到关于此的任何相关信息或修复,因此我们将不胜感激。泰!
PyScreenshot 用于截取桌面应用程序的屏幕截图。由于您的应用程序 运行 在服务器上,因此没有什么可以截图的。
如果您打算截取用户浏览器的屏幕截图,you would use frontend tooling,它在浏览器中运行,而不是服务器端工具。