从 Python Extension Packages for Windows – Christoph Gohlke 下载的windows上的igraph安装文件
python_igraph‑0.7.1.post6‑cp35‑none‑win_amd64.whl
使用igraph的plot函数画图出错,错误信息为
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) C:\Program Files\Anaconda3\lib\site-packages\IPython\core\formatters.py in __call__(self, obj) 309 method = get_real_method(obj, self.print_method) 310 if method is not None: --> 311 return method() 312 return None 313 else: C:\Program Files\Anaconda3\lib\site-packages\igraph\drawing\__init__.py in _repr_svg_(self) 352 surface.finish() 353 # Return the raw SVG representation --> 354 return io.getvalue().encode("utf-8") 355 356 @property AttributeError: 'bytes' object has no attribute 'encode' |
提示 AttributeError: ‘bytes’ object has no attribute ‘encode’、
这是因为,python3中,编码的时候区分了字符串和二进制
将Anaconda3\lib\site-packages\igraph\drawing\__init__.py的第354行中的 encode 改为 decode 就可以了