在Heroku上部署编剧python

x33g5p2x  于 2022-11-24  发布在  Python
关注(0)|答案(3)|浏览(124)

我正在使用一个python模块,在我的heroku flask应用程序中使用了playwright。该模块的安装说明要求我安装如下浏览器二进制文件:

python -m playwright install

当我在本地部署它时,它可以工作,但我似乎无法将浏览器二进制安装合并到部署中。我曾尝试使用heroku playwright buildpack(https://github.com/mxschmitt/heroku-playwright-buildpack),但这似乎不起作用,并且我得到如下错误:

2020-11-17T23:06:42.252585+00:00 app[web.1]: "webkit" browser was not found.
2020-11-17T23:06:42.252585+00:00 app[web.1]: Please complete Playwright installation via running
2020-11-17T23:06:42.252585+00:00 app[web.1]: 
2020-11-17T23:06:42.252586+00:00 app[web.1]:     "python -m playwright install"

我也试过在buildpack中手动添加 python -m playwright install 命令,但是这也不起作用。有没有办法在heroku中使用playwright正确安装二进制文件?

bqucvtff

bqucvtff1#

Heroku当时并不支持webkit,在其他浏览器上,你可以使用这个构建包:https://github.com/mxschmitt/heroku-playwright-buildpack/

0ve6wy6x

0ve6wy6x2#

对我有效的解决方案是将以下内容添加到我的python代码中,但我100%肯定这不是正确的解决方案:

from subprocess import Popen, PIPE

p = Popen([sys.executable, "-m", "playwright", "install"], stdin=PIPE, stdout=PIPE, stderr=PIPE)
#output, err = p.communicate()
#print(output)
svgewumm

svgewumm3#

问题是webkit,尝试使用chrome或firefox。

相关问题