I can't seem to get WeasyPrint to work on Windows with Python 3.4 or 3.5. Has anyone been able to do this? There aren't forums at weasyprint.org and the IRC channel is dead.
我似乎无法用Python 3.4或3.5来在Windows上工作。有人能做到吗?在黄鼠会网站上没有论坛,而IRC频道已经死了。
I've been able to install using both Python 3.4.3 and 3.5.1. I've followed the guideline found here [1]. I've also made note that WeasyPrint's site claims it should work with Python 2.6+ or 3.1+.
我已经能够使用Python 3.4.3和3.5.1进行安装。我遵循了这里的指导原则[1]。我还注意到黄鼠狼的网站声称它应该使用Python 2.6+或3.1+。
When I install for Python 3.4.3 and open the Python shell and simply 'import weasyprint' I get this:
当我安装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
>>>
I get a similar traceback when importing in Python 3.5.1, with the exception of the final TypeError being:
当在Python 3.5.1中导入时,我得到了一个类似的回溯,除了最后的类型错误:
TypeError: a bytes-like object is required, not 'str'
[1] https://gist.github.com/doobeh/3188318
[1]https://gist.github.com/doobeh/3188318
1 个解决方案
#1
0
I had looked through the issues list at weasyprint.org and didn't find anyone else complaining about Python 3.x compatibility with WeasyPrint. Then I happened upon a pull request that did complain about just that and mirrors my difficulties exactly. So off the shelf it does not work with Python 3.x, but with a small hack it does, see [1]. I'll add some comments to the pull request and hopefully this incompatibility will get looked at.
我已经查看了在weasyprint.org上的问题列表,没有发现其他人抱怨Python 3。x与WeasyPrint的兼容性。然后,我遇到了一个请求,它确实抱怨了我的困难,并且完全反映了我的困难。所以在架子上它与python3不兼容。x,但是有一个小的hack,可以看到[1]。我将在pull请求中添加一些注释,希望这种不兼容性会得到关注。
[1] https://github.com/Kozea/WeasyPrint/pull/132
[1]https://github.com/Kozea/WeasyPrint/pull/132
#1
0
I had looked through the issues list at weasyprint.org and didn't find anyone else complaining about Python 3.x compatibility with WeasyPrint. Then I happened upon a pull request that did complain about just that and mirrors my difficulties exactly. So off the shelf it does not work with Python 3.x, but with a small hack it does, see [1]. I'll add some comments to the pull request and hopefully this incompatibility will get looked at.
我已经查看了在weasyprint.org上的问题列表,没有发现其他人抱怨Python 3。x与WeasyPrint的兼容性。然后,我遇到了一个请求,它确实抱怨了我的困难,并且完全反映了我的困难。所以在架子上它与python3不兼容。x,但是有一个小的hack,可以看到[1]。我将在pull请求中添加一些注释,希望这种不兼容性会得到关注。
[1] https://github.com/Kozea/WeasyPrint/pull/132
[1]https://github.com/Kozea/WeasyPrint/pull/132