2014-01-06 72 views
0

我試圖用MEGAM和NLTK。/usr/lib/python2.7/subprocess.py OSError:[Errno 2]沒有這樣的文件或目錄

這是我的代碼:

import nltk 
import os 
megam_path = os.path.expanduser("~/nltk_data/megam_i686.opt") 
nltk.config_megam(megam_path) 
me_classifier = MaxentClassifier.train(train_feats,  algorithm='megam') 
print me_classifier.show_most_informative_features(n=4) 
print("accuracy of Maxent Classifier : ", accuracy(me_classifier, test_feats)) 

當運行該文件的輸出是:

[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 31      9,  in train 
     gaussian_prior_sigma, **cutoffs) 
     File "/usr/local/lib/python2.7/dist- 
packages/nltk/classify/maxent.py", line 15       22, 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 

但文件subprocess.py存在。

任何提示或建議?

+0

我面臨同樣的問題。它的megma文件問題。讓我知道你是否仍然面臨這個問題。 –

回答

0

這不是關於subprocess.py文件。 subprocess.Popen()啓動一個子進程。檢查cmd是否在$PATH。您可能需要安裝一些命令行實用程序才能使用MaxentClassifier

相關問題