简体   繁体   English

Graphlab创建SArray应用AttributeError:“模块”对象没有属性“连接”

[英]Graphlab Create SArray apply AttributeError: 'module' object has no attribute 'connect'

I'm having trouble applying a function to the values in an SArray object in Graphlab Create (python). 我在将函数应用于Graphlab Create(python)中的SArray对象中的值时遇到麻烦。 The example given in the documentation even fails for me. 文档中给出的示例对我来说甚至失败。

sa = SArray([1,2,3,4,5])
sa[sa.apply(lambda x: math.log(x) <= 1)]

returns the following: 返回以下内容:

RuntimeError: Runtime Exception: 0. Runtime Exception: 0. Traceback (most recent call last):
File "/usr/lib/python2.7/pickle.py", line 1382, in loads
return Unpickler(file).load()
File "/usr/lib/python2.7/pickle.py", line 858, in load
dispatch[key](self)
File "/usr/lib/python2.7/pickle.py", line 1090, in load_global
klass = self.find_class(module, name)
File "/usr/lib/python2.7/pickle.py", line 1124, in find_class
__import__(module)
File "/Library/Python/2.7/site-packages/graphlab/__init__.py", line 7, in <module>
import graphlab.connect.aws as aws
AttributeError: 'module' object has no attribute 'connect'

This can be caused by having multiple Python installations on the machine (the __import__ through pickle seems to work differently from regular Python imports and may try to load the module from a different path). 这可能是由于在计算机上安装了多个Python而引起的(通过pickle的__import__似乎与常规的Python导入不同,并可能尝试从不同的路径加载模块)。

The workaround for this is to run in a virtualenv , with a pip install of graphlab-create inside the virtualenv. 解决方法是在virtualenv中运行,并在virtualenv中安装graphlab-create的pip安装。 That should isolate the Python module loading to the correct Python installation and module path. 那应该将Python模块加载隔离到正确的Python安装和模块路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM