python-2.7gensimlatent-semantic-indexingpyro4

AttributeError module 'Pyro4' has no attribute 'expose' while running gensim distributed LSI


So I am trying to run the demo from gensim for distributed LSI (You can find it here) Yet whenever I run the code I get the error

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

I have checked similar issues here on stackoverflow, and usually they are caused through misuse of the library.

However I am not using Pyro4 directly, I am using Distributed LSI introduced by gensim. So there is no room for mistakes on my side (or so I believe)

My code is really simple you can find it below

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

Solution

  • 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