我似乎无法让WeasyPrint在使用Python 3.4或3.5的Windows上运行。有没有人能够做到这一点? weasyprint.org上没有论坛,IRC频道已经死了。
我已经能够使用Python 3.4.3和3.5.1进行安装。我遵循了此处的指南[1]。我还注意到WeasyPrint的网站声称它应该适用于Python 2.6+或3.1 +。
当我安装Python 3.4.3并打开Python shell并简单地导入weasyprint'我明白了:
C:\Python34>python
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import weasyprint
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python34\lib\site-packages\weasyprint\__init__.py", line 337, in <module>
from .html import find_base_url, HTML5_UA_STYLESHEET, get_html_metadata # noqa
File "C:\Python34\lib\site-packages\weasyprint\html.py", line 41, in <module>
HTML5_UA_STYLESHEET = CSS(filename=os.path.join(root, 'css', 'html5_ua.css'))
File "C:\Python34\lib\site-packages\weasyprint\__init__.py", line 224, in __init__
with result as (source_type, source, base_url, protocol_encoding):
File "C:\Python34\lib\contextlib.py", line 59, in __enter__
return next(self.gen)
File "C:\Python34\lib\site-packages\weasyprint\__init__.py", line 294, in _select_source
base_url = path2url(filename)
File "C:\Python34\lib\site-packages\weasyprint\urls.py", line 87, in path2url
path = pathname2url(path)
File "C:\Python34\lib\nturl2path.py", line 46, in pathname2url
if not ':' in p:
TypeError: 'str' does not support the buffer interface
>>>
在Python 3.5.1中导入时,我获得了类似的回溯,但最终的TypeError除外:
TypeError: a bytes-like object is required, not 'str'
答案 0 :(得分:0)
我查看了weasyprint.org上的问题列表,但没有发现其他人抱怨Python 3.x与WeasyPrint的兼容性。然后我遇到了一个拉扯请求,这个请求确实抱怨了这一点并完全反映了我的困难。所以现成的它不与Python 3.x一起使用,但是它有一个小的黑客,见[1]。我将在pull请求中添加一些注释,希望能够看到这种不兼容性。