首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在使用imgkit时遇到问题

在使用imgkit时遇到问题
EN

Stack Overflow用户
提问于 2019-02-07 03:57:30
回答 1查看 1.1K关注 0票数 0

当涉及到python时,我是个新手。因此,可能有一个相当简单的解决方案。

我正在尝试使用imgkit捕获网页的截图。但是,在pycharm中运行脚本时,我一直收到以下错误:

代码语言:javascript
复制
Traceback (most recent call last):
  File "C:\Users\name\PycharmProject\websitescreenshot\venv\lib\site-packages\imgkit\config.py", line 30, in __init__
    with open(self.wkhtmltoimage):
FileNotFoundError: [Errno 2] No such file or directory: b''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/name/PycharmProject/websitescreenshot/Test.py", line 3, in <module>
    imgkit.from_url('https://pypi.org/project/imgkit/', 'out.jpg')
  File "C:\Users\name\PycharmProject\websitescreenshot\venv\lib\site-packages\imgkit\api.py", line 31, in from_url
    cover_first=cover_first)
  File "C:\Users\name\PycharmProject\websitescreenshot\venv\lib\site-packages\imgkit\imgkit.py", line 34, in __init__
    self.config = Config() if not config else config
  File "C:\Users\name\PycharmProject\websitescreenshot\venv\lib\site-packages\imgkit\config.py", line 36, in __init__
    'http://wkhtmltopdf.org\n'.format(self.wkhtmltoimage))
OSError: No wkhtmltoimage executable found: "b''"
If this file exists please check that this process can read it. Otherwise please install wkhtmltopdf - http://wkhtmltopdf.org


Process finished with exit code 1

代码:

代码语言:javascript
复制
import imgkit

imgkit.from_url('http://google.com', 'out.jpg')
EN

回答 1

Stack Overflow用户

发布于 2019-06-12 19:11:37

您看到崩溃是因为PATH变量中缺少wkhtmltopdf,或者您的系统中没有安装它。通过您的包管理器安装工具后,它应该可以工作。

对于Ubuntu运行:

代码语言:javascript
复制
sudo apt-get install wkhtmltopdf
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54561585

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档