Я пытаюсь обучить свои собственные данные, используя оболочку granim wordrank.Я следую по этой ссылке на модель поезда.Я установил переменную path_to_wordrank_binary для пути к каталогу wordrank в моей системе Ubuntu, содержащем файл wordrank.cpp.Но все равно я получаю следующую ошибку:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/gensim/models/wrappers/wordrank.py", line 229, in train
utils.check_output(args=cmd)
File "/usr/local/lib/python2.7/dist-packages/gensim/utils.py", line 1870, in check_output
process = subprocess.Popen(stdout=stdout, shell=True, *popenargs, **kwargs)
File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
Ниже приведен код, из которого вызывается метод util.check_out из файла wordrank.py:
# run wordrank executable with wr_args
cmd = ['mpirun', '-np', str(np), os.path.join(wr_path, 'wordrank')]
for option, value in wr_args.items():
cmd.append('--%s' % option)
cmd.append(str(value))
logger.info("Running wordrank binary")
utils.check_output(args=cmd)
, а ниже приведен кодФункция check_out из файла utils.py:
def check_output(stdout=subprocess.PIPE, *popenargs, **kwargs):
r"""Run OS command with the given arguments and return its output as a byte string.
Backported from Python 2.7 with a few minor modifications. Widely used for :mod:`gensim.models.wrappers`.
Behaves very similar to https://docs.python.org/2/library/subprocess.html#subprocess.check_output.
Examples
--------
>>> from gensim.utils import check_output
>>> check_output(args=['echo', '1'])
'1\n'
Raises
------
KeyboardInterrupt
If Ctrl+C pressed.
"""
try:
logger.debug("COMMAND: %s %s", popenargs, kwargs)
process = subprocess.Popen(stdout=stdout, shell=True, *popenargs, **kwargs)
output, unused_err = process.communicate()
retcode = process.poll()
if retcode:
cmd = kwargs.get("args")
if cmd is None:
cmd = popenargs[0]
error = subprocess.CalledProcessError(retcode, cmd)
error.output = output
raise error
return output
except KeyboardInterrupt:
process.terminate()
raise
Я пытался решить эту проблему.Любое другое решение предлагает включить shell=True
в качестве аргумента функции Popen
.Я тоже так пытаюсь, но не смог решить проблему.
Может кто-нибудь, пожалуйста, помогите мне, это касается?