在运行gensim分布式LSI时,AttributeError模块'Pyro4'没有属性'expose'

时间:2017-07-30 19:48:11

标签: python-2.7 gensim latent-semantic-indexing pyro4

所以我试图从gensim为分布式LSI运行演示(你可以找到它here)但是每当我运行代码时我都会收到错误

AttributeError: module 'Pyro4' has no attribute 'expose'

我在stackoverflow上检查了类似的问题,通常它们是由于滥用库造成的。

但是我没有直接使用Pyro4,我正在使用gensim引入的分布式LSI。所以我身边没有犯错的余地(或者我相信)

我的代码很简单,你可以在下面找到它

from gensim import corpora, models, utils
import logging, os, Pyro4
logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO)
os.environ["PYRO_SERIALIZERS_ACCEPTED"] =  'pickle'
os.environ["PYRO_SERIALIZER"] = 'pickle'

corpus = corpora.MmCorpus('wiki_corpus.mm') # load a corpus of nine documents, from the Tutorials
id2word = corpora.Dictionary.load('wiki_dict.dict')

lsi = models.LsiModel(corpus, id2word=id2word, num_topics=200, chunksize=1, distributed=True) # run distributed LSA on nine documents

1 个答案:

答案 0 :(得分:1)

Pyro4.expose was added in Pyro4 version 4.27 from august 2014. It looks to me that you have a very old Pyro4 version installed from before this date, and that your gensim requires a more recent one.

Check using:

$ python -m Pyro4.configuration | head -3

You should probably upgrade your Pyro4 library... Pay attention though, I believe gensim doesn't support the most recent versions of Pyro4 so you should probably check its manual for the correct version that you need. You can always try to install the latest (4.61 right now) and see how it goes.

edit I suppose you could also try to find gensim specific support? https://radimrehurek.com/gensim/support.html