【问题标题】:Gensim fasttext wrapper returns permission error 13 while model trainingGensim fasttext wrapper 在模型训练时返回权限错误 13
【发布时间】:2019-04-08 02:24:10
【问题描述】:

我尝试在本地机器上重现 this tutorial 以适应 gensim fasttext 功能。 Fasttext 和 gensim 库已正确安装。通过调用gensim fasttext wrapper的train方法

model_wrapper = FT_wrapper.train(ft_home, lee_train_file)

我收到以下错误:

---------------------------------------------------------------------------
PermissionError                           Traceback (most recent call last)
<ipython-input-19-0815ab031d23> in <module>()
      3 
      4 # train the model
----> 5 model_wrapper = FT_wrapper.train(ft_home, lee_train_file)
      6 
      7 print(model_wrapper)

~/anaconda3/lib/python3.6/site-packages/gensim/models/deprecated/fasttext_wrapper.py in train(cls, ft_path, corpus_file, output_file, model, size, alpha, window, min_count, word_ngrams, loss, sample, negative, iter, min_n, max_n, sorted_vocab, threads)
    240             cmd.append(str(value))
    241 
--> 242         utils.check_output(args=cmd)
    243         model = cls.load_fasttext_format(output_file)
    244         cls.delete_training_files(output_file)

~/anaconda3/lib/python3.6/site-packages/gensim/utils.py in check_output(stdout, *popenargs, **kwargs)
   1795     try:
   1796         logger.debug("COMMAND: %s %s", popenargs, kwargs)
-> 1797         process = subprocess.Popen(stdout=stdout, *popenargs, **kwargs)
   1798         output, unused_err = process.communicate()
   1799         retcode = process.poll()

~/anaconda3/lib/python3.6/subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors)
    707                                 c2pread, c2pwrite,
    708                                 errread, errwrite,
--> 709                                 restore_signals, start_new_session)
    710         except:
    711             # Cleanup if the child failed starting.

~/anaconda3/lib/python3.6/subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, start_new_session)
   1342                         if errno_num == errno.ENOENT:
   1343                             err_msg += ': ' + repr(err_filename)
-> 1344                     raise child_exception_type(errno_num, err_msg, err_filename)
   1345                 raise child_exception_type(err_msg)
   1346 

PermissionError: [Errno 13] Permission denied: '/Users/marcomattioli/fastText'

请注意,我对 fasttext 可执行文件具有 -rwxr-xr-x 权限。任何帮助感谢如何解决这个问题。

【问题讨论】:

    标签: file-permissions gensim fasttext


    【解决方案1】:

    这些方法已弃用。

    使用以下代码:

    from gensim.models.fasttext import FastText
    from gensim.test.utils import datapath
    corpus_file = datapath('lee_background.cor')  # absolute path to corpus
    model3 = FastText(size=4, window=3, min_count=1)
    model3.build_vocab(corpus_file=corpus_file)
    total_words = model3.corpus_total_words
    model3.train(corpus_file=corpus_file, total_words=total_words, epochs=10)
    

    【讨论】:

      猜你喜欢
      • 2019-11-23
      • 1970-01-01
      • 2021-03-29
      • 2018-11-11
      • 2019-02-04
      • 2020-06-26
      • 2019-11-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多