0

我使用python的datashader 0.5.0包来绘制人口密度信息,通常遵循教程https://www.continuum.io/blog/developer-blog/analyzing-and-visualizing-big-data-interactively-your-laptop -datashading-2010-us。我使用conda install -c bokeh datashader=0.5.0.

一切都很好。尽管可能不相关,但一旦我安装了 haloviews 和 geoviews 软件包,事情似乎就崩溃了。安装这些附加软件包后,我无法再导入数据着色器,并且我曾经工作的代码不再运行。导入数据着色器时,出现以下错误: AttributeError: module 'snappy' has no attribute 'compress'

我在 Windows 10、anaconda python 3.5.3 上运行。

也许我走错了兔子洞,但我想也许是时髦的包裹。我跑了“conda install -c conda-forge snappy=1.1.4”。conda list 显示已安装 snappy。Snappy 确实导入了。找不到 snappy.compress 对象。我的问题似乎与以下 SO 帖子有关,因为我在尝试 geoviews 时也遇到了 fastparquet 错误:在 python 中导入 fastparquet时出现 snappy 错误

运行时import snappyprint(snappy.__filename__)出现以下错误:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-5-b8565733b383> in <module>()
----> 1 import snappy; print(snappy.__file__)

AttributeError: module 'snappy' has no attribute '__file__'

为了以防万一,我还尝试通过 conda 和 pip 卸载。仍然没有喜悦。

运行“pip install python-snappy”会导致“python-snappy 的构建轮失败”错误,前面有“错误:需要 Microsoft Visual C++ 14.0...”所以我去获取“Microsoft Visual C++ Redistributable for Visual Studio 2017”并运行它,但没有任何变化。

关于如何解决这个问题的任何想法?作为参考,datashader导入的完整错误如下:

--------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-7-3d7b1ff9e530> in <module>()
----> 1 import datashader

C:\Python\lib\site-packages\datashader\__init__.py in <module>()
      3 __version__ = '0.5.0'
      4 
----> 5 from .core import Canvas
      6 from .reductions import (count, any, sum, min, max, mean, std, var, count_cat,
      7                          summary)

C:\Python\lib\site-packages\datashader\core.py in <module>()
      3 import numpy as np
      4 from datashape.predicates import istabular
----> 5 from odo import discover
      6 from xarray import DataArray
      7 

C:\Python\lib\site-packages\odo\__init__.py in <module>()
     63     from .backends.url import URL
     64 with ignoring(ImportError):
---> 65     from .backends.dask import dask
     66 
     67 

C:\Python\lib\site-packages\odo\backends\dask.py in <module>()
      8 
      9 from dask.array.core import Array, from_array
---> 10 from dask.bag.core import Bag
     11 import dask.bag as db
     12 from dask.compatibility import long

C:\Python\lib\site-packages\dask\bag\__init__.py in <module>()
      1 from __future__ import absolute_import, division, print_function
      2 
----> 3 from .core import (Bag, Item, from_sequence, from_url, to_textfiles, concat,
      4                    from_delayed, map_partitions, bag_range as range,
      5                    bag_zip as zip, bag_map as map)

C:\Python\lib\site-packages\dask\bag\core.py in <module>()
     30 
     31 from ..base import Base, normalize_token, tokenize
---> 32 from ..bytes.core import write_bytes
     33 from ..compatibility import apply, urlopen
     34 from ..context import _globals, defer_to_globals

C:\Python\lib\site-packages\dask\bytes\__init__.py in <module>()
      2 
      3 from ..utils import ignoring
----> 4 from .core import read_bytes, open_files, open_text_files
      5 
      6 from . import local

C:\Python\lib\site-packages\dask\bytes\core.py in <module>()
      7 from warnings import warn
      8 
----> 9 from .compression import seekable_files, files as compress_files
     10 from .utils import (SeekableFile, read_block, infer_compression,
     11                     infer_storage_options, build_name_function)

C:\Python\lib\site-packages\dask\bytes\compression.py in <module>()
     30 with ignoring(ImportError):
     31     import snappy
---> 32     compress['snappy'] = snappy.compress
     33     decompress['snappy'] = snappy.decompress
     34 

AttributeError: module 'snappy' has no attribute 'compress'
4

1 回答 1

0

事实证明,在添加软件包时,一些东西搞砸了 snappy 安装。我遵循了这个解决方案:如何在 Windows 10 上安装 snappy C 库以在 Anaconda 中与 python-snappy 一起使用? 这是一个活泼的错误,而不是数据着色器问题,但我会留下帖子,以防有人遇到相同系列的问题。

于 2017-07-04T03:56:27.347 回答