TypeError:在Python 2.7上安装CairoSVG和WeazyPrint时的'encoding'

时间:2017-02-25 00:37:15

标签: python

在Dockerfile上安装CairoSVG和WeazyPrint时,我不断收到这个TypeError:

Collecting WeasyPrint
  Downloading WeasyPrint-0.34.tar.gz (391kB)
Collecting cairosvg
  Downloading CairoSVG-2.0.1.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-pSKp0y/cairosvg/setup.py", line 24, in <module>
        with open(init_path, 'r', encoding='utf-8') as fd:
    TypeError: 'encoding' is an invalid keyword argument for this function

1 个答案:

答案 0 :(得分:6)

经过一些research,我发现CairoSVG-2.x适用于Python 3+。安装1.x版本时问题解决了:

pip install cairosvg==1.0.22