diging / tethne

Python module for bibliographic network analysis.
http://diging.github.io/tethne/
GNU General Public License v3.0
81 stars 32 forks source link

RuntimeError: MALLET import-file failed with exit code 127 #152

Closed kevinbsc closed 8 years ago

kevinbsc commented 8 years ago

I am running Tethne on Ubuntu. The following error is captured. The same code works fine in Windows 10 (tested).

`RuntimeError Traceback (most recent call last)

in () ----> 1 model = mallet.LDAModel(metadata, featureset_name='abstract') 2 model.Z = 20 3 model.max_iter = 500 /home/bc/anaconda2/lib/python2.7/site-packages/tethne/model/corpus/mallet.pyc in **init**(self, _args, *_kwargs) 140 self.mallet_bin += '.bat' 141 os.putenv('MALLET_HOME', self.mallet_path) --> 142 super(LDAModel, self).**init**(_args, *_kwargs) 143 144 def prep(self): /home/bc/anaconda2/lib/python2.7/site-packages/tethne/model/**init**.pyc in **init**(self, corpus, **kwargs) 35 setattr(self, key, value) 36 ---> 37 self.prep() 38 39 def **del**(self): /home/bc/anaconda2/lib/python2.7/site-packages/tethne/model/corpus/mallet.pyc in prep(self) 147 self.om = os.path.join(self.temp, "model.mallet") 148 --> 149 self._generate_corpus() 150 151 def _generate_corpus(self): /home/bc/anaconda2/lib/python2.7/site-packages/tethne/model/corpus/mallet.pyc in _generate_corpus(self) 159 self.corpus_path, self.metapath = paths 160 --> 161 self._export_corpus() 162 163 def _export_corpus(self): /home/bc/anaconda2/lib/python2.7/site-packages/tethne/model/corpus/mallet.pyc in _export_corpus(self) 182 if exit != 0: 183 msg = "MALLET import-file failed with exit code {0}.".format(exit) --> 184 raise RuntimeError(msg) 185 186 def run(self, **kwargs): RuntimeError: MALLET import-file failed with exit code 127. `
erickpeirson commented 8 years ago

Hey @kevinbsc thanks for the bug report. Can you provide the following, so that we can figure out what's going on:

Thanks!

kevinbsc commented 8 years ago

Thanks for your prompt response!

erickpeirson commented 8 years ago

@kevinbsc Thanks, that helps. Looks like tethne is having trouble finding MALLET. We should take a look at how the path provided to subprocess is generated, there must be something platform-specific going on there. This will be TETHNE-129.

erickpeirson commented 8 years ago

@kevinbsc What version of Ubuntu? I have made several tweaks, any of which might help, but I'd feel a lot better if I could replicate the problem. I'll spin up a vbox and try to mimic your setup, and see what happens.

Our CI service (Travis) actually builds on Ubuntu 12.04, which makes me worry that is a bit more complicated. But I'll keep poking at it.

kevinbsc commented 8 years ago

I am using Ubuntu 14.04.4 LTS

Thanks!

erickpeirson commented 8 years ago

Ok, setting up the box this morning. In the meantime: It's not documented yet, but LDAModel lets you override quite a few parameters on initialization. Try initializing LDAModel with mallet_bin, which should be the full path to the MALLET executable. For example, on my system:

>>> model = LDAModel(corpus, featureset_name='wordcounts_uberfiltered', 
                             mallet_bin='/Users/erickpeirson/mallet-2.0.7/bin/mallet')

I'd be curious to know if you get the same errors if you specify mallet_bin explicitly.

erickpeirson commented 8 years ago

@kevinbsc I have been working under the (undersupported) theory that the 127 was due to Tethne not finding MALLET. But there's a good chance it's due to an inability to find Java. On a fresh base Ubuntu 14.04 Java is not installed, and attempting to use LDAModel raises the same 127 exit code.

What happens when you try to run Java from the command line?

kevinbsc commented 8 years ago

@erickpeirson I installed Mallet in Ubuntu.

git clone https://github.com/mimno/Mallet.git ant

This resolved the issue. Thanks for your help.

erickpeirson commented 8 years ago

@kevinbsc Fantastic! We should really fix the exceptions in that module so that they are more informative.

By the way, I just set up a Google Q/A group for Tethne users: (https://groups.google.com/forum/#!forum/tethne-users). If you're willing, it would be great to have your participation in getting it rolling. There are quite a few people who are new to Python and attempting to use Tethne, and I'm hoping this can be a resource (especially since I'm so slow at updating documentation).