MEGAM: /usr/lib/python2.7/subprocess.py OSError: [Errno 13] Permission denied

3,198 views
Skip to first unread message

Marco Ippolito

unread,
Jan 3, 2014, 9:54:55 AM1/3/14
to nltk-...@googlegroups.com
Hi everybody,

thanks to hints of Alex and others, I was able to "import" MEGAM file and run without memory shortages.
But now the output is:
Traceback (most recent call last):
  File "classifying.py", line 492, in <module>
    me_classifier = MaxentClassifier.train(train_feats, algorithm='megam')
  File "/usr/local/lib/python2.7/dist-packages/nltk/classify/maxent.py", line 319, in train
    gaussian_prior_sigma, **cutoffs)
  File "/usr/local/lib/python2.7/dist-packages/nltk/classify/maxent.py", line 1522, in train_maxent_classifier_with_megam
    stdout = call_megam(options)
  File "/usr/local/lib/python2.7/dist-packages/nltk/classify/megam.py", line 167, in call_megam
    p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
  File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child
    raise child_exception
OSError: [Errno 13] Permission denied

Any hints to solve it?

Thanks in advance.
Marco

Alex Rudnick

unread,
Jan 5, 2014, 10:37:42 PM1/5/14
to nltk-...@googlegroups.com
Hey Marco!

Did you figure it out?

One possibility is that your script doesn't have permission to execute
the megam binary -- does it have the execute bit set? I get a similar
error when I try to use subprocess to call a binary with the execute
bits turned off.

Consider going:
$ chmod ugo+rx /path/to/megam
Let us know whether this helps!

--
-- alexr

Marco Ippolito

unread,
Jan 6, 2014, 6:48:15 AM1/6/14
to nltk-...@googlegroups.com
Hi Alex,
thank you for your kind helpfull suggestion.

After changing megam permissions through:
$chmod ugo+rx ~/nltk_data/megam_i686.opt

-rwxrwxr-x 1 ubuntu ubuntu 977748 Oct 8 2007 megam_i686.opt

The error changed from being "permission denied" to being "no such
file or directory":

[Found /home/ubuntu/nltk_data/megam_i686.opt:
/home/ubuntu/nltk_data/megam_i686.opt]
Traceback (most recent call last):
File "classifying.py", line 494, in <module>
me_classifier = MaxentClassifier.train(train_feats, algorithm='megam')
File "/usr/local/lib/python2.7/dist-packages/nltk/classify/maxent.py",
line 319, in train
gaussian_prior_sigma, **cutoffs)
File "/usr/local/lib/python2.7/dist-packages/nltk/classify/maxent.py",
line 1522, in train_maxent_classifier_with_megam
stdout = call_megam(options)
File "/usr/local/lib/python2.7/dist-packages/nltk/classify/megam.py",
line 167, in call_megam
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory

Any other suggestions?

Thank you very much for your help.

Marco

2014/1/6 Alex Rudnick <alex.r...@gmail.com>:
> --
> You received this message because you are subscribed to a topic in the Google Groups "nltk-users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/nltk-users/X2nld28FYBw/unsubscribe.
> To unsubscribe from this group and all of its topics, send an email to nltk-users+...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Marco Ippolito

unread,
Jan 6, 2014, 6:57:59 AM1/6/14
to nltk-...@googlegroups.com
Hi Alex and hi everybody,
to integrate my previous post, subprocess.py exists:

# subprocess - Subprocesses with accessible I/O streams
#
# For more information about this module, see PEP 324.
#
# This module should remain compatible with Python 2.2, see PEP 291.
#
# Copyright (c) 2003-2005 by Peter Astrand <ast...@lysator.liu.se>
#
# Licensed to PSF under a Contributor Agreement.
# See http://www.python.org/2.4/license for licensing details.

r"""subprocess - Subprocesses with accessible I/O streams


Any ideas?

Kind regards
Marco

2014/1/6 Marco Ippolito <ippolit...@gmail.com>:

Marco Ippolito

unread,
Jan 6, 2014, 3:02:25 PM1/6/14
to nltk-...@googlegroups.com
Hi Alex and everybody,
I added to my code these lines:
import subprocess

subprocess.call(["/usr/local/lib/python2.7/dist-packages/nltk/classify/maxent.py","/usr/local/lib/pyth\
on2.7/dist-packages/nltk/classify/megam.py","/home/ubuntu/nltk_data/megam_i686.opt"])

but now running the file the result is:

  File "classifying.py", line 496, in <module>
    subprocess.call(["/usr/local/lib/python2.7/dist-packages/nltk/classify/maxent.py","/usr/local/lib/python2.7/dist-packages/nltk/classify/megam.py","/home/ubuntu/nltk_data/megam_i686.opt"])
  File "/usr/lib/python2.7/subprocess.py", line 493, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child
    raise child_exception

OSError: [Errno 13] Permission denied

even if:
-rwxrwxr-x 1 ubuntu ubuntu  977748 Oct  8  2007 megam_i686.opt

Any more suggestions?

Kind regards.
Marco
>> To unsubscribe from this group and all of its topics, send an email to nltk-users+unsubscribe@googlegroups.com.

Mirko Otto

unread,
Jan 6, 2014, 8:46:56 PM1/6/14
to nltk-...@googlegroups.com
Hello,

ok I think nltk can not find the executable file because you have not given the correct path.

megam_i686.opt is your executable file, is that correct? Then, the path should be as follows
nltk.config_megam('/home/ubuntu/nltk_data')

I think then it might work.

Cheers,
Mirko


--
You received this message because you are subscribed to the Google Groups "nltk-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nltk-users+...@googlegroups.com.

Ranjeet Kumar

unread,
Jul 18, 2015, 12:34:27 PM7/18/15
to nltk-...@googlegroups.com
Hi 
After adding 
megam_path = os.path.expanduser("/path/megma/megam_i686.opt")
nltk.config_megam(megam_path)

It  wroked.
>> To unsubscribe from this group and all of its topics, send an email to nltk-users+...@googlegroups.com.

tanlik...@gmail.com

unread,
Apr 5, 2016, 4:56:27 AM4/5/16
to nltk-users
Did you ever figure out the issue? I am having the exact same problem...
>> To unsubscribe from this group and all of its topics, send an email to nltk-users+...@googlegroups.com.

Alexis

unread,
Apr 5, 2016, 6:41:36 AM4/5/16
to nltk-...@googlegroups.com
I don't know what the original problem was (or yours), but this call to subprocess is all wrong. The first argument must be the name of an *executable* in your PATH (or a full path), i.e. "python", "/usr/bin/python3", etc. 

If your nltk can't find the megam binary, use nltk.classify.megam.config_megam("/path/to/megam") to tell it where it is. 
If you have a different problem, please ask here properly by describing your set-up, what you're trying to do, and the problem you're having.

Alexis


Dr. Alexis Dimitriadis | Assistant Professor and Senior Research Fellow | Utrecht Institute of Linguistics OTS | Utrecht University | Trans 10, 3512 JK Utrecht, room 2.33 | +31 30 253 65 68 | a.dimi...@uu.nl | www.hum.uu.nl/medewerkers/a.dimitriadis

You received this message because you are subscribed to the Google Groups "nltk-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nltk-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages